
19 Aug
2021
19 Aug
'21
2:32 p.m.
Dear Rasmus,
In message 62540f7b-0e07-8759-8e12-125527c2edec@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.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de
No, I'm not going to explain it. If you can't figure it out, you
didn't want to know anyway... :-)
- Larry Wall in 1991Aug7.180856.2854@netlabs.com