[PATCH RESEND] video: au1100fb: Move a variable assignment behind a null pointer check in au1100fb_setmode()
Uwe Kleine-König
u.kleine-koenig at baylibre.com
Mon Mar 3 10:30:46 UTC 2025
On Mon, Mar 03, 2025 at 01:08:29PM +0300, Dan Carpenter wrote:
> On Mon, Mar 03, 2025 at 10:19:06AM +0100, Uwe Kleine-König wrote:
> > Hello,
> >
> > On Sun, Mar 02, 2025 at 07:02:12PM +0100, Markus Elfring wrote:
> > > From: Markus Elfring <elfring at users.sourceforge.net>
> > > Date: Thu, 13 Apr 2023 21:35:36 +0200
> > >
> > > The address of a data structure member was determined before
> > > a corresponding null pointer check in the implementation of
> > > the function “au1100fb_setmode”.
> > >
> > > Thus avoid the risk for undefined behaviour by moving the assignment
> > > for the variable “info” behind the null pointer check.
> > >
> > > This issue was detected by using the Coccinelle software.
> > >
> > > Fixes: 3b495f2bb749 ("Au1100 FB driver uplift for 2.6.")
> > > Signed-off-by: Markus Elfring <elfring at users.sourceforge.net>
> >
> > Acked-by: Uwe Kleine-König <u.kleine-koenig at baylibre.com>
> >
> > Should also get
> >
> > Cc: stable at vger.kernel.org
> >
> > to ensure this is backported to stable.
>
> It's not a bugfix, it's a cleanup. That's not a dereference, it's
> just pointer math. It shouldn't have a Fixes tag.
>
> Real bugs where we dereference a pointer and then check for NULL don't
> last long in the kernel. Most of the stuff Markus is sending is false
> positives like this.
I thought a compiler translating the code
struct fb_info *info = &fbdev->info;
if (!fbdev)
return -EINVAL;
is free (and expected) to just drop the if block. I wasn't aware that
this only applies when the pointer is actually dereferenced. Testing
that with arm-linux-gnueabihf-gcc 14.2.0 seems to confirm what you're
saying.
Thanks for letting me know. With that learned I agree that the Fixes tag
should be dropped (and Cc: stable not added).
Best regards
Uwe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20250303/51138ee5/attachment-0003.sig>
More information about the dri-devel
mailing list