
On Thu, Aug 19, 2021 at 02:32:01PM +0200, Wolfgang Denk wrote:
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.
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.