Skip to content

Commit

Permalink
net: mctp i3c: Copy headers if cloned
Browse files Browse the repository at this point in the history
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: c8755b2 ("mctp i3c: MCTP I3C driver")
Link: https://patch.msgid.link/20250306-matt-i3c-cow-head-v1-1-d5e6a5495227@codeconstruct.com.au
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Matt Johnston authored and Jakub Kicinski committed Mar 8, 2025
1 parent dc5340c commit 26db9c9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/net/mctp/mctp-i3c.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,10 +506,15 @@ static int mctp_i3c_header_create(struct sk_buff *skb, struct net_device *dev,
const void *saddr, unsigned int len)
{
struct mctp_i3c_internal_hdr *ihdr;
int rc;

if (!daddr || !saddr)
return -EINVAL;

rc = skb_cow_head(skb, sizeof(struct mctp_i3c_internal_hdr));
if (rc)
return rc;

skb_push(skb, sizeof(struct mctp_i3c_internal_hdr));
skb_reset_mac_header(skb);
ihdr = (void *)skb_mac_header(skb);
Expand Down

0 comments on commit 26db9c9

Please sign in to comment.