[PATCH v6 10/12] watchdog: add gpio watchdog driver
Tom Rini
trini at konsulko.com
Thu Aug 19 14:35:40 CEST 2021
On Thu, Aug 19, 2021 at 02:32:01PM +0200, Wolfgang Denk wrote:
> Dear Rasmus,
>
> In message <62540f7b-0e07-8759-8e12-125527c2edec at prevas.dk> you wrote:
> >
> > >> +static int gpio_wdt_reset(struct udevice *dev)
> > >> +{
> > >> + struct gpio_wdt_priv *priv = dev_get_priv(dev);
> > >> +
> > >> + priv->state = !priv->state;
> > >
> > > Potential NULL pointer dereference.
> >
> > No, no and no. If allocation of the (driver or uclass) private data
> > fails, the device probe would have failed, so this code can never get
> > called with such a struct udevice.
>
> Famous last words...
>
> > Perhaps try doing a
> >
> > git grep -10 -E 'dev_get(_uclass)?_priv'
> >
> > and see how many cases you can find where that is followed by a NULL check?
>
> The existence of bad code is not a justification to add more of it.
Since I literally just sent this in another email you couldn't have seen
yet, I'll repeat it here. Feel free to follow up to this with a series
to further update things, Wolfgang.
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210819/1b71592f/attachment.sig>
More information about the U-Boot
mailing list