Re: [PATCH 2/9] EDAC/versalnet: Add NULL check for mci in remove_one_mc()

Borislav Petkov <[email protected]> Sun, 2 Aug 2026 11:46:23 -0700
Newsgroups org.kernel.vger.linux-edac,org.kernel.vger.linux-kernel
Message-ID <20260802184623.GAam-Qf9-yes1DkNkl@fat_crate.local>
On Fri, Jul 24, 2026 at 10:49:38PM +0530, Shubhrajyoti Datta wrote:
> If a controller's configuration specifies an unrecognized bus width,

When can that happen?

We did figure out that controllers cannot be non-contiguous.

> init_one_mc() returns 0 but skips allocating priv->mci[ctl_num], leaving
> it NULL. On module unload or probe failure, remove_one_mc() is called for
> all controllers and unconditionally dereferences priv->mci[i], causing a
> kernel panic.
> 
> Add a NULL pointer check for mci before dereferencing it.
> 
>  Unable to handle kernel NULL pointer dereference at virtual address 0000000000000390
>  Internal error: Oops: 0000000096000004 [#1] SMP
>  Hardware name: Xilinx Versal NET VNX (DT)
>  pc : mc_remove+0x34/0x88
>  lr : mc_remove+0x4c/0x88
>  Call trace:
>   mc_remove+0x34/0x88
>   platform_remove+0x2c/0x70
>   device_remove+0x48/0x7c
>   device_release_driver_internal+0x1c8/0x224
>   device_driver_detach+0x18/0x28
>   unbind_store+0xb4/0xb8

How did you trigger this?

The commit message needs to explain the scenario this can happen in.

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette