Re: [PATCH net-next v1] net: core: fix logical inconsistency in failover_slave_register()

From: Simon Horman

Date: Thu Feb 19 2026 - 04:44:51 EST


On Thu, Feb 19, 2026 at 02:02:16PM +0500, Zeeshan Ahmad wrote:
> Smatch warns that 'fops' is dereferenced at line 66 before being checked
> for NULL at line 85.
>
> The current code inconsistently assumes 'fops' might be NULL at lines 62
> and 85, while dereferencing it without a check at line 66.
>
> Move the NULL check to the beginning of the function immediately after
> 'fops' is initialized. This ensures safety for all subsequent
> dereferences and allows the removal of redundant checks.
>
> Signed-off-by: Zeeshan Ahmad <zeeshanahmad022019@xxxxxxxxx>

Hi Zeeshan,

It's not entirely clear to me what the behaviour should be if fops is
NULL, or indeed if fops can be NULL.

But looking over both this function and other users of failover_get_bymac()
it seems to me that the general patter is to skip steps that needs
to dereference fops if fops is NULL.

So I think it would be best to do the same here - that is modify the
code around line 66 to make it conditional on fops not being NULL.
Otherwise, if fops is NULL then steps that would have been taken are skipped.

It is true that in those steps would never be reached and the kernel would
have panic'ed due to a NULL dereference on line 66. So maybe your
approach is better, perhaps with the addition of a WARN_ON_ONCE.
But I feel that opens a larger surface that needs to be fixed in terms
of understanding other users of failover_get_bymac() and if they (still)
need to take fops being NULL into account.

LMKWYT


On process, if this is a fix - which I think means there is at least
a theoretical case where it can go *boom* - then please target at net
rather than net-next, and include a Fixes tag.

Else,

## Form letter - net-next-closed

We have already submitted our pull request with net-next material for v7.0,
and therefore net-next is closed for new drivers, features, code refactoring
and optimizations. We are currently accepting bug fixes only.

Please repost when net-next reopens after Feb 23rd.

RFC patches sent for review only are obviously welcome at any time.
See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#development-cycle
--
pw-bot: defer