Re: [PATCH net 1/2] devlink: param: do not dereference a missing param item
From: Simon Horman
Date: Mon Nov 02 2026 - 07:12:29 EST
On Fri, Oct 30, 2026 at 11:33:31AM +0800, Linkui Xiao wrote:
> From: Linkui Xiao <xiaolinkui@xxxxxxxxxx>
>
> 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@xxxxxxxxxx>
> Link: https://lore.kernel.org/all/20230126075838.1643665-5-jiri@xxxxxxxxxxx/
Reviewed-by: Simon Horman <horms@xxxxxxxxxx>