Skip to content

Commit df8ce77

Browse files
mkjkuba-moo
authored andcommitted
net: mctp i2c: Copy headers if cloned
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>
1 parent 26db9c9 commit df8ce77

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
@@ -583,6 +583,7 @@ static int mctp_i2c_header_create(struct sk_buff *skb, struct net_device *dev,
583583
struct mctp_i2c_hdr *hdr;
584584
struct mctp_hdr *mhdr;
585585
u8 lldst, llsrc;
586+
int rc;
586587

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

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

0 commit comments

Comments
 (0)