# \[PATCH AUTOSEL 5.13 155/219\] selftests: nci: Fix the wrong condition

- Subsystems: NFC VIRTUAL NCI DEVICE DRIVER, KERNEL SELFTEST FRAMEWORK, NFC SUBSYSTEM, THE REST
- Maintainers: Bongsu Jeon, Shuah Khan, Shuah Khan, David Heidelberg, Linus Torvalds
- List: netdev
- 1 message, 1 author
- Page: https://ratatoskr.run/netdev/2021/09/1501554/t

## \[PATCH AUTOSEL 5.13 155/219\] selftests: nci: Fix the wrong condition

- From: Sasha Levin \<sashal@kernel.org\>
- Date: 2021-09-09 12:27:54 
- Message: https://ratatoskr.run/netdev/2021/09/1501554.md

```text
From: Bongsu Jeon <bongsu.jeon@samsung.com>

[ Upstream commit 1d5b8d01db98abb8c176838fad73287366874582 ]

memcpy should be executed only in case nla_len's value is greater than 0.

Signed-off-by: Bongsu Jeon <bongsu.jeon@samsung.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 tools/testing/selftests/nci/nci_dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/nci/nci_dev.c b/tools/testing/selftests/nci/nci_dev.c
index 9687100f15ea..acd4125ff39f 100644
--- a/tools/testing/selftests/nci/nci_dev.c
+++ b/tools/testing/selftests/nci/nci_dev.c
@@ -110,7 +110,7 @@ static int send_cmd_mt_nla(int sd, __u16 nlmsg_type, __u32 nlmsg_pid,
 		na->nla_type = nla_type[cnt];
 		na->nla_len = nla_len[cnt] + NLA_HDRLEN;
 
-		if (nla_len > 0)
+		if (nla_len[cnt] > 0)
 			memcpy(NLA_DATA(na), nla_data[cnt], nla_len[cnt]);
 
 		prv_len = NLA_ALIGN(nla_len[cnt]) + NLA_HDRLEN;
-- 
2.30.2

```
