Thread (16 messages) flat view 16 messages, 5 authors, 2021-08-23

Re: [PATCH] PCI: rockchip-dwc: Potential error pointer dereference in probe

From: Mark Brown <broonie@kernel.org>
Date: 2021-08-13 15:56:36
Also in: kernel-janitors, linux-pci, linux-rockchip

On Fri, Aug 13, 2021 at 06:45:05PM +0300, Dan Carpenter wrote:
On Fri, Aug 13, 2021 at 03:32:50PM +0100, Mark Brown wrote:
quoted
On Fri, Aug 13, 2021 at 03:01:10PM +0100, Robin Murphy wrote:
quoted
quoted
Indeed I've thought before that it would be nice if regulators worked like
GPIOs, where the absence of an optional one does give you NULL, and most of
the API is also NULL-safe. Probably a pretty big job though...
quoted
It also encourages *really* bad practice with error handling
I'm not necessarily 100% positive what you mean by this.  I think you
mean you don't like when people pass invalid pointers to free functions?
No, it's the case where people don't bother checking if they got the
regulator in the first place, don't bother checking if when they tried
to enable the regulator that actually worked, and don't do whatever
extra handling they need to do to configure the system for the fact that
one of the power supplies is missing.  It really only helps in the case
where you can just ignore the regulator completely.
But making regulator code NULL-safe wouldn't affect error handling
because NULL wouldn't be an error.

	p = get_optional();
	if (IS_ERR(p))
		return PTR_ERR(p);
	enable(p);
Your example already misses the error handling on enable...
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help