On 3/18/26 00:23, Ethan Tidmore wrote:
> The function find_cfg_context_attr() can return an error pointer or NULL
> in its error path.
>
> Change NULL check to IS_ERR_OR_NULL().
>
> Detected by Smatch:
> drivers/block/drbd/drbd_nl.c:6571 drbd_adm_dump_paths() error:
> 'resource_filter' dereferencing possible ERR_PTR()
>
> Fixes: 626c95b0e2a23 ("drbd: rework netlink interface for DRBD 9 multi-peer config")
> Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
> ---
> drivers/block/drbd/drbd_nl.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
> index c5e253820ccf..1f458eb972e9 100644
> --- a/drivers/block/drbd/drbd_nl.c
> +++ b/drivers/block/drbd/drbd_nl.c
> @@ -6566,7 +6566,7 @@ static int drbd_adm_dump_paths(struct sk_buff *skb, struct netlink_callback *cb)
> resource = (struct drbd_resource *)cb->args[0];
> if (!cb->args[0]) {
> resource_filter = find_cfg_context_attr(cb->nlh, T_ctx_resource_name);
> - if (resource_filter) {
> + if (!IS_ERR_OR_NULL(resource_filter)) {
> retcode = ERR_RES_NOT_KNOWN;
> resource = drbd_find_resource(nla_data(resource_filter));
> if (!resource)
find_cfg_context_attr is also called identically in 3 other cases, so
these have the same issue.
I've also fixed these 3 cases in my squash.
Regards,
Christoph