]> git.hungrycats.org Git - linux/commitdiff
mctp i2c: handle NULL header address
authorMatt Johnston <matt@codeconstruct.com.au>
Tue, 22 Oct 2024 10:25:14 +0000 (18:25 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Nov 2024 15:26:46 +0000 (16:26 +0100)
[ Upstream commit 01e215975fd80af81b5b79f009d49ddd35976c13 ]

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.

Fixes: f5b8abf9fc3d ("mctp i2c: MCTP I2C binding driver")
Cc: stable@vger.kernel.org
Reported-by: Dung Cao <dung@os.amperecomputing.com>
Signed-off-by: Matt Johnston <matt@codeconstruct.com.au>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20241022-mctp-i2c-null-dest-v3-1-e929709956c5@codeconstruct.com.au
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/mctp/mctp-i2c.c

index 1d67a3ca1fd1168979c1912eb48c52751a6b7380..7635a8b3c35cdef5c00bbb80eef562ea776844db 100644 (file)
@@ -547,6 +547,9 @@ static int mctp_i2c_header_create(struct sk_buff *skb, struct net_device *dev,
        if (len > MCTP_I2C_MAXMTU)
                return -EMSGSIZE;
 
+       if (!daddr || !saddr)
+               return -EINVAL;
+
        lldst = *((u8 *)daddr);
        llsrc = *((u8 *)saddr);