mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Colin Ian King <colin.king@canonical.com>
To: Nishanth Menon <nm@ti.com>
Cc: MyungJoo Ham <myungjoo.ham@samsung.com>,
	Kyungmin Park <kyungmin.park@samsung.com>,
	Chanwoo Choi <cw00.choi@samsung.com>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	Linux PM <linux-pm@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	linux-samsung-soc@vger.kernel.org
Subject: Re: PM / devfreq: map devfreq drivers to governor using name
Date: Wed, 28 Oct 2020 12:04:58 +0000	[thread overview]
Message-ID: <e110c917-e65a-1e1b-925d-945cb99eef9a@canonical.com> (raw)
In-Reply-To: <8aec701c-73d1-d2a1-c894-8dec844ed865@canonical.com>

On 28/10/2020 12:00, Colin Ian King wrote:
> Hi,
> 
> Static analysis of linux-next with Coverity has found a potential null
> pointer dereference issue with the following commit:
> 
> commit 1b5c1be2c88e8445a20fa1929e26c37e7ca8c926
> Author: Nishanth Menon <nm@ti.com>
> Date:   Mon Oct 29 15:01:45 2012 -0500
> 
>     PM / devfreq: map devfreq drivers to governor using name
> 
> 
> The analysis is as follows for devfreq_remove_governor in
> drivers/devfreq/devfreq.c
> 
> 1312
> 
> deref_ptr_in_call: Dereferencing pointer devfreq->governor.
> 
> 1313                if (!strncmp(devfreq->governor->name, governor->name,
> 1314                             DEVFREQ_NAME_LEN)) {
> 1315                        /* we should have a devfreq governor! */
> 
> Dereference before null check (REVERSE_INULL)
> check_after_deref: Null-checking devfreq->governor suggests that it may
> be null, but it has already been dereferenced on all paths leading to
> the check.
> 
> 1316                        if (!devfreq->governor) {
> 1317                                dev_warn(dev, "%s: Governor %s NOT
> present\n",
> 1318                                         __func__, governor->name);
> 1319                                continue;
> 1320                                /* Fall through */
> 
> So devfreq->governor->name is dereferencing devfreq->governor before a
> null check on devfreq->governor
> 
> Colin
> 

I forgot to mention, an identical issue also exists here:

1247        list_for_each_entry(devfreq, &devfreq_list, node) {
1248                int ret = 0;
1249                struct device *dev = devfreq->dev.parent;
1250

deref_ptr_in_call: Dereferencing pointer devfreq->governor.

1251                if (!strncmp(devfreq->governor->name, governor->name,
1252                             DEVFREQ_NAME_LEN)) {
1253                        /* The following should never occur */

Dereference before null check (REVERSE_INULL)
check_after_deref: Null-checking devfreq->governor suggests that it may
be null, but it has already been dereferenced on all paths leading to
the check.

1254                        if (devfreq->governor) {
1255                                dev_warn(dev,
1256                                         "%s: Governor %s already
present\n",
1257                                         __func__,
devfreq->governor->name);


      reply	other threads:[~2020-10-29  0:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-28 12:00 Colin Ian King
2020-10-28 12:04 ` Colin Ian King [this message]

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=e110c917-e65a-1e1b-925d-945cb99eef9a@canonical.com \
    --to=colin.king@canonical.com \
    --cc=cw00.choi@samsung.com \
    --cc=krzk@kernel.org \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=myungjoo.ham@samsung.com \
    --cc=nm@ti.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®