[PATCH 1/4] taskstats: use nla_put_u32() in mk_reply()
From: Bradley Morgan
Date: Sat Oct 31 2026 - 20:58:03 EST
mk_reply() open codes a u32 attribute, nla_put() with sizeof(pid) and
&pid fed to it by hand. nla_put_u32() is those same three arguments
already collapsed, and it is what the readers of this attribute use.
The helper returns 0 or a negative error, so the bare if() catches
exactly what the < 0 comparison caught.
No functional change.
Signed-off-by: Bradley Morgan <brads@xxxxxxxxxxxxxx>
---
kernel/taskstats.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/taskstats.c b/kernel/taskstats.c
index bf517788b8409..37422c43b8caa 100644
--- a/kernel/taskstats.c
+++ b/kernel/taskstats.c
@@ -386,7 +386,7 @@ static struct taskstats *mk_reply(struct sk_buff *skb, int type, u32 pid)
if (!na)
goto err;
- if (nla_put(skb, type, sizeof(pid), &pid) < 0) {
+ if (nla_put_u32(skb, type, pid)) {
nla_nest_cancel(skb, na);
goto err;
}
--
2.53.0