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

"Pandey, Radhey Shyam" <[email protected]> Mon, 27 Jul 2026 12:18:48 +0530
Newsgroups org.kernel.vger.linux-edac,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On 7/27/2026 5:22 AM, Borislav Petkov wrote:
> On Fri, Jul 24, 2026 at 10:49:37PM +0530, Shubhrajyoti Datta wrote:
>> diff --git a/drivers/edac/versalnet_edac.c b/drivers/edac/versalnet_edac.c
>> index d1af5e175f7e..316f8f79c4d8 100644
>> --- a/drivers/edac/versalnet_edac.c
>> +++ b/drivers/edac/versalnet_edac.c
>> @@ -439,6 +439,8 @@ static void handle_error(struct mc_priv  *priv, struct ecc_status *stat,
>>   		return;
>>   
>>   	mci = priv->mci[ctl_num];
>> +	if (!mci)
>> +		return;
> 
> You have a WARN_ON_ONCE right before that line which checks against
> NUM_CONTROLLERS and init_versalnet() unwinds all the setup the moment
> init_one_mc() fails for one of the MCs.

The gap in the driver is that init_one_mc() returns success without
setting priv->mci[i] when the bus width decodes to DEV_UNKNOWN, while
buggy firmware / future firmware rpmsg error path can still calls
handle_error().

Happy to drop the check if you prefer otherwise we can keep it as a
cheap guard for a firmware/driver mismatch.

Shubrajyoti: Please feel free to add/correct. I'm still ramping up on
this driver and may have overlooked details.

> 
> So why are we adding dead code?
>