From: Linkui Xiao <xiaolinkui@126.com>
To: jiri@resnulli.us, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, horms@kernel.org
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Linkui Xiao <xiaolinkui@kylinos.cn>
Subject: [PATCH net 1/2] devlink: param: do not dereference a missing param item
Date: Fri, 30 Oct 2026 11:33:31 +0800 [thread overview]
Message-ID: <20261030033332.3685172-2-xiaolinkui@126.com> (raw)
In-Reply-To: <20261030033332.3685172-1-xiaolinkui@126.com>
From: Linkui Xiao <xiaolinkui@kylinos.cn>
devl_param_value_changed() looks the param item up by id and only warns
when the lookup fails. devlink_param_notify() is called with the result
regardless, and devlink_nl_param_fill() dereferences param_item->param
in its very first statement, so a driver that passes a param_id which is
not registered on this instance turns the warning into a NULL pointer
dereference.
Every other user of devlink_param_find_by_id() handles the NULL result:
devlink_param_unregister() and devl_param_driverinit_value_set() return
right after the same warning, devl_param_driverinit_value_get() returns
-EINVAL. Do the same here so that a bogus param_id costs a warning
instead of an oops.
Fixes: ea601e170988 ("devlink: Add devlink notifications support for params")
Signed-off-by: Linkui Xiao <xiaolinkui@kylinos.cn>
Link: https://lore.kernel.org/all/20230126075838.1643665-5-jiri@resnulli.us/
---
net/devlink/param.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/devlink/param.c b/net/devlink/param.c
index 95ac9db8c993..474fe009f22d 100644
--- a/net/devlink/param.c
+++ b/net/devlink/param.c
@@ -1008,7 +1008,8 @@ void devl_param_value_changed(struct devlink *devlink, u32 param_id)
struct devlink_param_item *param_item;
param_item = devlink_param_find_by_id(&devlink->params, param_id);
- WARN_ON(!param_item);
+ if (WARN_ON(!param_item))
+ return;
devlink_param_notify(devlink, 0, param_item, DEVLINK_CMD_PARAM_NEW);
}
--
2.25.1
next prev parent reply other threads:[~2026-10-30 3:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 3:33 [PATCH net 0/2] devlink: do not dereference a missing param item or shared buffer Linkui Xiao
2026-10-30 3:33 ` Linkui Xiao [this message]
2026-10-30 3:33 ` [PATCH net 2/2] devlink: sb: do not dereference a missing " Linkui Xiao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261030033332.3685172-2-xiaolinkui@126.com \
--to=xiaolinkui@126.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=xiaolinkui@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®