Re: [PATCH] firmware: arm_scmi: Fix late checks on pointer dereference

From: Cristian Marussi
Date: Wed May 04 2022 - 02:56:09 EST


On Wed, May 04, 2022 at 09:44:36AM +0300, Dan Carpenter wrote:
> On Tue, May 03, 2022 at 01:10:47PM +0100, Cristian Marussi wrote:
> > A few dereferences could happen before the iterator pointer argument was
> > checked for NULL, causing the following smatch warnings:
> >
> > drivers/firmware/arm_scmi/driver.c:1214 scmi_iterator_run() warn: variable
> > dereferenced before check 'i' (see line 1210)
> >
> > Fix by moving the checks early and dropping some unneeded local references.
> >
> > No functional change.
>

Hi Dan,

thanks for you feedback first of all.

> If there is no chance these can be NULL then a different option is to
> just delete the NULL checks.

Indeed, I think I kept only the checks on iter param that can possibly
be NULL if the caller messes up the usage of this iterator interface
(or if the internals are messed up by future developments...just to
play on the safe side).

Thanks,
Cristian