On Sat, 13 Jun 2026 16:33:44 -0700 Xiang Mei wrote:
quoted hunk ↗ jump to hunk
That looks better. I just found that nla_reserve can memset for us:
diff --git a/net/psample/psample.c b/net/psample/psample.c
index 7763662036fb..c112e1f0ccac 100644
--- a/net/psample/psample.c
+++ b/net/psample/psample.c
@@ -476,12 +476,11 @@ void psample_sample_packet(struct psample_group *group,
goto error;
if (data_len) {
- int nla_len = nla_total_size(data_len);
struct nlattr *nla;
- nla = skb_put(nl_skb, nla_len);
- nla->nla_type = PSAMPLE_ATTR_DATA;
- nla->nla_len = nla_attr_size(data_len);
+ nla = nla_reserve(nl_skb, PSAMPLE_ATTR_DATA, data_len);
+ if (!nla)
+ goto error;
if (skb_copy_bits(skb, 0, nla_data(nla), data_len))
goto error;
Let me know if the new patch makes sense.
I assumed the author intentionally was avoiding the memset for
the memory we will override with data. Otherwise the whole dance
could be avoided and nla_put() would have been the answer.