All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: "Robin Murphy" <robin.murphy@arm.com>,
	"Lorenzo Pieralisi" <lorenzo.pieralisi@arm.com>,
	"Simon Xue" <xxm@rock-chips.com>, "Rob Herring" <robh@kernel.org>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Heiko Stuebner" <heiko@sntech.de>,
	"Liam Girdwood" <lgirdwood@gmail.com>,
	"Kever Yang" <kever.yang@rock-chips.com>,
	"Shawn Lin" <shawn.lin@rock-chips.com>,
	linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-rockchip@lists.infradead.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] PCI: rockchip-dwc: Potential error pointer dereference in probe
Date: Fri, 13 Aug 2021 16:53:50 +0100	[thread overview]
Message-ID: <20210813155350.GC5209@sirena.org.uk> (raw)
In-Reply-To: <20210813154505.GC7722@kadam>

[-- Attachment #1: Type: text/plain, Size: 1322 bytes --]

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:
> > On Fri, Aug 13, 2021 at 03:01:10PM +0100, Robin Murphy wrote:

> > > 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...

> > 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...

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Mark Brown <broonie@kernel.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: "Robin Murphy" <robin.murphy@arm.com>,
	"Lorenzo Pieralisi" <lorenzo.pieralisi@arm.com>,
	"Simon Xue" <xxm@rock-chips.com>, "Rob Herring" <robh@kernel.org>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Heiko Stuebner" <heiko@sntech.de>,
	"Liam Girdwood" <lgirdwood@gmail.com>,
	"Kever Yang" <kever.yang@rock-chips.com>,
	"Shawn Lin" <shawn.lin@rock-chips.com>,
	linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-rockchip@lists.infradead.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] PCI: rockchip-dwc: Potential error pointer dereference in probe
Date: Fri, 13 Aug 2021 16:53:50 +0100	[thread overview]
Message-ID: <20210813155350.GC5209@sirena.org.uk> (raw)
In-Reply-To: <20210813154505.GC7722@kadam>


[-- Attachment #1.1: Type: text/plain, Size: 1322 bytes --]

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:
> > On Fri, Aug 13, 2021 at 03:01:10PM +0100, Robin Murphy wrote:

> > > 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...

> > 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...

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

WARNING: multiple messages have this Message-ID (diff)
From: Mark Brown <broonie@kernel.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: "Robin Murphy" <robin.murphy@arm.com>,
	"Lorenzo Pieralisi" <lorenzo.pieralisi@arm.com>,
	"Simon Xue" <xxm@rock-chips.com>, "Rob Herring" <robh@kernel.org>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Heiko Stuebner" <heiko@sntech.de>,
	"Liam Girdwood" <lgirdwood@gmail.com>,
	"Kever Yang" <kever.yang@rock-chips.com>,
	"Shawn Lin" <shawn.lin@rock-chips.com>,
	linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-rockchip@lists.infradead.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] PCI: rockchip-dwc: Potential error pointer dereference in probe
Date: Fri, 13 Aug 2021 16:53:50 +0100	[thread overview]
Message-ID: <20210813155350.GC5209@sirena.org.uk> (raw)
In-Reply-To: <20210813154505.GC7722@kadam>


[-- Attachment #1.1: Type: text/plain, Size: 1322 bytes --]

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:
> > On Fri, Aug 13, 2021 at 03:01:10PM +0100, Robin Murphy wrote:

> > > 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...

> > 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...

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-08-13 15:54 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-13 11:33 [PATCH] PCI: rockchip-dwc: Potential error pointer dereference in probe Dan Carpenter
2021-08-13 11:33 ` Dan Carpenter
2021-08-13 11:33 ` Dan Carpenter
2021-08-13 12:55 ` Robin Murphy
2021-08-13 12:55   ` Robin Murphy
2021-08-13 12:55   ` Robin Murphy
2021-08-13 13:34   ` Rob Herring
2021-08-13 13:34     ` Rob Herring
2021-08-13 13:34     ` Rob Herring
2021-08-13 13:47     ` Robin Murphy
2021-08-13 13:47       ` Robin Murphy
2021-08-13 13:47       ` Robin Murphy
2021-08-13 15:57       ` Rob Herring
2021-08-13 15:57         ` Rob Herring
2021-08-13 15:57         ` Rob Herring
2021-08-13 16:01         ` Mark Brown
2021-08-13 16:01           ` Mark Brown
2021-08-13 16:01           ` Mark Brown
2021-08-13 13:54   ` Dan Carpenter
2021-08-13 13:54     ` Dan Carpenter
2021-08-13 13:54     ` Dan Carpenter
2021-08-13 14:01     ` Robin Murphy
2021-08-13 14:01       ` Robin Murphy
2021-08-13 14:01       ` Robin Murphy
2021-08-13 14:12       ` Dan Carpenter
2021-08-13 14:12         ` Dan Carpenter
2021-08-13 14:12         ` Dan Carpenter
2021-08-13 14:26         ` [PATCH v2] " Dan Carpenter
2021-08-13 14:26           ` Dan Carpenter
2021-08-13 14:26           ` Dan Carpenter
2021-08-23 16:15           ` Lorenzo Pieralisi
2021-08-23 16:15             ` Lorenzo Pieralisi
2021-08-23 16:15             ` Lorenzo Pieralisi
2021-08-13 14:32       ` [PATCH] " Mark Brown
2021-08-13 14:32         ` Mark Brown
2021-08-13 14:32         ` Mark Brown
2021-08-13 15:00         ` Robin Murphy
2021-08-13 15:00           ` Robin Murphy
2021-08-13 15:00           ` Robin Murphy
2021-08-13 15:30           ` Mark Brown
2021-08-13 15:30             ` Mark Brown
2021-08-13 15:30             ` Mark Brown
2021-08-13 15:45         ` Dan Carpenter
2021-08-13 15:45           ` Dan Carpenter
2021-08-13 15:45           ` Dan Carpenter
2021-08-13 15:53           ` Mark Brown [this message]
2021-08-13 15:53             ` Mark Brown
2021-08-13 15:53             ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210813155350.GC5209@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=dan.carpenter@oracle.com \
    --cc=heiko@sntech.de \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kever.yang@rock-chips.com \
    --cc=kw@linux.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=robh@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=shawn.lin@rock-chips.com \
    --cc=xxm@rock-chips.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.