net/sched: cls_api: Support hardware miss to tc action
Hello Paul Blakey,
The patch 80cd22c35c90: "net/sched: cls_api: Support hardware miss to tc action" from Feb 18, 2023, leads to the following Smatch static checker warning:
net/sched/cls_api.c:102 tcf_exts_miss_cookie_base_alloc() warn: xa_alloc_cyclic() also returns 1 on success
net/sched/cls_api.c
92
93 n->chain_index = tp->chain->index;
94 n->chain = tp->chain;
95 n->tp_prio = tp->prio;
96 n->tp = tp;
97 n->exts = exts;
98 n->handle = handle;
99
100 err = xa_alloc_cyclic(&tcf_exts_miss_cookies_xa, &n->miss_cookie_base,
101 n, xa_limit_32b, &next, GFP_KERNEL);--> 102 if (err)
xa_alloc_cyclic() returns 1 if it succeeds after wrapping. I don't know if that applies here, but I feel like this check would be better as "if (err < 0)".
103 goto err_xa_alloc;
104
105 exts->miss_cookie_node = n;
106 return 0;
107
108 err_xa_alloc:
109 kfree(n);
110 return err;
111 }regards,
dan carpenter
Quoted 7 lines · Dan Carpenter
100 err = xa_alloc_cyclic(&tcf_exts_miss_cookies_xa, &n->miss_cookie_base, 101 n, xa_limit_32b, &next, GFP_KERNEL);--> 102 if (err)
xa_alloc_cyclic()returns 1 if it succeeds after wrapping. I don't know if that applies here, but I feel like this check would be better as "if (err < 0)".
Smatch is correct, it should be err < 0.