]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mctp i3c: handle NULL header address
authorMatt Johnston <matt@codeconstruct.com.au>
Tue, 4 Mar 2025 05:59:51 +0000 (13:59 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Mar 2025 12:02:09 +0000 (13:02 +0100)
[ Upstream commit cf7ee25e70c6edfac4553d6b671e8b19db1d9573 ]

daddr can be NULL if there is no neighbour table entry present,
in that case the tx packet should be dropped.

saddr will usually be set by MCTP core, but check for NULL in case a
packet is transmitted by a different protocol.

Signed-off-by: Matt Johnston <matt@codeconstruct.com.au>
Fixes: c8755b29b58e ("mctp i3c: MCTP I3C driver")
Link: https://patch.msgid.link/20250304-mctp-i3c-null-v1-1-4416bbd56540@codeconstruct.com.au
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/mctp/mctp-i3c.c

index ee9d562f0817cfd3274cdf860c05db3c254d1218..a2b15cddf46e6ba7cc3d60c53eca16567f46125d 100644 (file)
@@ -507,6 +507,9 @@ static int mctp_i3c_header_create(struct sk_buff *skb, struct net_device *dev,
 {
        struct mctp_i3c_internal_hdr *ihdr;
 
+       if (!daddr || !saddr)
+               return -EINVAL;
+
        skb_push(skb, sizeof(struct mctp_i3c_internal_hdr));
        skb_reset_mac_header(skb);
        ihdr = (void *)skb_mac_header(skb);