Re: [PATCH net v3] net: core: failover: fix NULL pointer dereference in failover_slave_register()

From: Dan Carpenter

Date: Thu Feb 26 2026 - 04:24:24 EST


On Thu, Feb 26, 2026 at 01:56:01PM +0500, Zeeshan Ahmad wrote:
> Smatch warns that 'fops' is dereferenced without a NULL check.
> While other callbacks in this function properly check 'fops', the
> rx_handler registration does not.
>
> Consolidate the NULL check for 'fops' at the beginning of the function,
> before it is first used in slave_pre_register(). This ensures 'fops' is
> valid for the entire function scope and allows the removal of redundant
> NULL checks later in the function, as suggested by Dan Carpenter.
>
> Fixes: 30c8bd5aa8b2 ("net: Introduce generic failover module")
> Signed-off-by: Zeeshan Ahmad <zeeshanahmad022019@xxxxxxxxx>
> ---
> v3:
> - Move the fops NULL check to the top of the function before any
> dereferences occur and remove subsequent redundant NULL checks,
> as suggested by Dan Carpenter.

Thanks!

Reviewed-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>

regards,
dan carpenter