[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250114074329.102691-1-liuye@kylinos.cn>
Date: Tue, 14 Jan 2025 15:43:29 +0800
From: liuye <liuye@...inos.cn>
To: steffen.klassert@...unet.com,
herbert@...dor.apana.org.au,
davem@...emloft.net,
edumazet@...gle.com,
kuba@...nel.org,
pabeni@...hat.com,
shuah@...nel.org
Cc: horms@...nel.org,
netdev@...r.kernel.org,
linux-kselftest@...r.kernel.org,
linux-kernel@...r.kernel.org,
liuye <liuye@...inos.cn>
Subject: [PATCH] selftests/net/ipsec: Fix Null pointer dereference in rtattr_pack()
Fix the following warning.
tools/testing/selftests/net/ipsec.c:230:25: warning: Possible null pointer
dereference: payload [nullPointer]
memcpy(RTA_DATA(attr), payload, size);
^
tools/testing/selftests/net/ipsec.c:1618:54: note: Calling function 'rtattr_pack',
4th argument 'NULL' value is 0
if (rtattr_pack(&req.nh, sizeof(req), XFRMA_IF_ID, NULL, 0)) {
^
tools/testing/selftests/net/ipsec.c:230:25: note: Null pointer dereference
memcpy(RTA_DATA(attr), payload, size);
^
Signed-off-by: liuye <liuye@...inos.cn>
---
tools/testing/selftests/net/ipsec.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/ipsec.c b/tools/testing/selftests/net/ipsec.c
index be4a30a0d02a..725310ac26a9 100644
--- a/tools/testing/selftests/net/ipsec.c
+++ b/tools/testing/selftests/net/ipsec.c
@@ -227,7 +227,8 @@ static int rtattr_pack(struct nlmsghdr *nh, size_t req_sz,
attr->rta_len = RTA_LENGTH(size);
attr->rta_type = rta_type;
- memcpy(RTA_DATA(attr), payload, size);
+ if (payload != NULL)
+ memcpy(RTA_DATA(attr), payload, size);
return 0;
}
--
2.25.1
Powered by blists - more mailing lists