Skip to content

Commit caff87a

Browse files
mkjgregkh
authored andcommitted
net: mctp i2c: Copy headers if cloned
[ Upstream commit df8ce77 ] Use skb_cow_head() prior to modifying the TX SKB. This is necessary when the SKB has been cloned, to avoid modifying other shared clones. Signed-off-by: Matt Johnston <matt@codeconstruct.com.au> Fixes: f5b8abf ("mctp i2c: MCTP I2C binding driver") Link: https://patch.msgid.link/20250306-matt-mctp-i2c-cow-v1-1-293827212681@codeconstruct.com.au Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 370dacb commit caff87a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/net/mctp/mctp-i2c.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ static int mctp_i2c_header_create(struct sk_buff *skb, struct net_device *dev,
584584
struct mctp_i2c_hdr *hdr;
585585
struct mctp_hdr *mhdr;
586586
u8 lldst, llsrc;
587+
int rc;
587588

588589
if (len > MCTP_I2C_MAXMTU)
589590
return -EMSGSIZE;
@@ -594,6 +595,10 @@ static int mctp_i2c_header_create(struct sk_buff *skb, struct net_device *dev,
594595
lldst = *((u8 *)daddr);
595596
llsrc = *((u8 *)saddr);
596597

598+
rc = skb_cow_head(skb, sizeof(struct mctp_i2c_hdr));
599+
if (rc)
600+
return rc;
601+
597602
skb_push(skb, sizeof(struct mctp_i2c_hdr));
598603
skb_reset_mac_header(skb);
599604
hdr = (void *)skb_mac_header(skb);

0 commit comments

Comments
 (0)