Linux Kernel Selftest development
 help / color / mirror / Atom feed
* [PATCH] selftests: nci: Fix uninitialized family ID on missing attribute
@ 2026-09-01  7:06 Chaithanya Lagisetty
  2026-09-01  9:04 ` Hangbin Liu
  0 siblings, 1 reply; 2+ messages in thread
From: Chaithanya Lagisetty @ 2026-09-01  7:06 UTC (permalink / raw)
  To: David Heidelberg, Bongsu Jeon, Shuah Khan, Jakub Kicinski
  Cc: oe-linux-nfc, netdev, linux-kselftest, linux-kernel,
	Chaithanya Lagisetty

get_family_id() walks the generic netlink CTRL_CMD_GETFAMILY reply
looking for the CTRL_ATTR_FAMILY_ID attribute and returns the parsed
value in the local variable "id". If the reply does not carry that
attribute, the parsing loop never assigns "id" and the function returns
an indeterminate stack value, which the caller stores in self->fid and
uses for subsequent netlink requests.

Initialize "id" to 0 so a missing attribute yields a deterministic
(invalid) family ID instead of a garbage value.

Fixes: f595cf1242f3 ("selftests: Add nci suite")
Signed-off-by: Chaithanya Lagisetty <nagachaithanya9911@gmail.com>
---
 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 312f84ee0444..ed306ec23895 100644
--- a/tools/testing/selftests/nci/nci_dev.c
+++ b/tools/testing/selftests/nci/nci_dev.c
@@ -182,7 +182,7 @@ static int get_family_id(int sd, __u32 pid, __u32 *event_group)
 	} ans;
 	struct nlattr *na;
 	int resp_len;
-	__u16 id;
+	__u16 id = 0;
 	int len;
 	int rc;
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] selftests: nci: Fix uninitialized family ID on missing attribute
  2026-09-01  7:06 [PATCH] selftests: nci: Fix uninitialized family ID on missing attribute Chaithanya Lagisetty
@ 2026-09-01  9:04 ` Hangbin Liu
  0 siblings, 0 replies; 2+ messages in thread
From: Hangbin Liu @ 2026-09-01  9:04 UTC (permalink / raw)
  To: Chaithanya Lagisetty
  Cc: David Heidelberg, Bongsu Jeon, Shuah Khan, Jakub Kicinski,
	oe-linux-nfc, netdev, linux-kselftest, linux-kernel

On Tue, Sep 01, 2026 at 07:06:18AM +0000, Chaithanya Lagisetty wrote:
> get_family_id() walks the generic netlink CTRL_CMD_GETFAMILY reply
> looking for the CTRL_ATTR_FAMILY_ID attribute and returns the parsed
> value in the local variable "id". If the reply does not carry that
> attribute, the parsing loop never assigns "id" and the function returns
> an indeterminate stack value, which the caller stores in self->fid and
> uses for subsequent netlink requests.
> 
> Initialize "id" to 0 so a missing attribute yields a deterministic
> (invalid) family ID instead of a garbage value.
> 
> Fixes: f595cf1242f3 ("selftests: Add nci suite")
> Signed-off-by: Chaithanya Lagisetty <nagachaithanya9911@gmail.com>
> ---
>  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 312f84ee0444..ed306ec23895 100644
> --- a/tools/testing/selftests/nci/nci_dev.c
> +++ b/tools/testing/selftests/nci/nci_dev.c
> @@ -182,7 +182,7 @@ static int get_family_id(int sd, __u32 pid, __u32 *event_group)
>  	} ans;
>  	struct nlattr *na;
>  	int resp_len;
> -	__u16 id;
> +	__u16 id = 0;
>  	int len;
>  	int rc;
>  
> -- 
> 2.43.0
> 

Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-01  9:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-01  7:06 [PATCH] selftests: nci: Fix uninitialized family ID on missing attribute Chaithanya Lagisetty
2026-09-01  9:04 ` Hangbin Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox