[PATCH] genl: fix ‘attr_grp.next_len’ may be used uninitialized
MaxLyubimov <[email protected]> Mon, 16 Oct 2023 23:39:58 +0500
| Newsgroups | dev.linux.lists.ell |
|---|---|
| Message-ID | <[email protected]> |
make --no-print-directory all-am
CC ell/genl.lo
ell/genl.c: In function ‘parse_cmd_newfamily.part.0’:
ell/genl.c:1728:5: error: ‘attr_grp.next_len’ may be used uninitialized
in this function [-Werror=maybe-uninitialized]
1728 | if (!NLA_OK(nla, attr->next_len))
| ^
ell/genl.c:268:22: note: ‘attr_grp.next_len’ was declared here
268 | struct l_genl_attr attr_grp;
| ^~~~~~~~
ell/genl.c:1732:14: error: ‘attr_grp.next_data’ may be used
uninitialized in this function [-Werror=maybe-uninitialized]
1732 | *type = nla->nla_type & NLA_TYPE_MASK;
| ~~~^~~~~~~~~~
ell/genl.c:268:22: note: ‘attr_grp.next_data’ was declared here
268 | struct l_genl_attr attr_grp;
| ^~~~~~~~
ell/genl.c:1728:5: error: ‘attr_op.next_len’ may be used uninitialized
in this function [-Werror=maybe-uninitialized]
1728 | if (!NLA_OK(nla, attr->next_len))
| ^
ell/genl.c:240:22: note: ‘attr_op.next_len’ was declared here
240 | struct l_genl_attr attr_op;
| ^~~~~~~
ell/genl.c:1732:14: error: ‘attr_op.next_data’ may be used
uninitialized in this function [-Werror=maybe-uninitialized]
1732 | *type = nla->nla_type & NLA_TYPE_MASK;
| ~~~^~~~~~~~~~
ell/genl.c:240:22: note: ‘attr_op.next_data’ was declared here
240 | struct l_genl_attr attr_op;
| ^~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:4032: ell/genl.lo] Error 1
make: *** [Makefile:2348: all] Error 2
---
ell/genl.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/ell/genl.c b/ell/genl.c
index def3790..33ecc4d 100644
--- a/ell/genl.c
+++ b/ell/genl.c
@@ -240,7 +240,8 @@ static void family_ops(struct l_genl_family_info
*info,
struct l_genl_attr attr_op;
uint32_t id = 0, flags = 0;
- l_genl_attr_recurse(attr, &attr_op);
+ if (!l_genl_attr_recurse(attr, &attr_op))
+ continue;
while (l_genl_attr_next(&attr_op, &type, &len, &data))
{
switch (type) {
@@ -269,7 +270,8 @@ static void family_mcast_groups(struct
l_genl_family_info *info,
const char *name = NULL;
uint32_t id = 0;
- l_genl_attr_recurse(attr, &attr_grp);
+ if (!l_genl_attr_recurse(attr, &attr_grp))
+ continue;
while (l_genl_attr_next(&attr_grp, &type, &len, &data))
{
switch (type) {