All of lore.kernel.org
 help / color / mirror / Atom feed
* [linux-next:master 1128/2532] drivers/pwm/core.c:1530 pwm_put() warn: variable dereferenced before check 'pwm' (see line 1528)
@ 2024-03-31 12:48 kernel test robot
  0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2024-03-31 12:48 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: Linux Memory Management List <linux-mm@kvack.org>
TO: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   a6bd6c9333397f5a0e2667d4d82fef8c970108f2
commit: d60bc2995732489766cbe650fc367e036ff6a0e0 [1128/2532] pwm: Add a struct device to struct pwm_chip
:::::: branch date: 3 days ago
:::::: commit date: 6 days ago
config: m68k-randconfig-r071-20240326 (https://download.01.org/0day-ci/archive/20240331/202403312030.QYCgiAey-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 13.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202403312030.QYCgiAey-lkp@intel.com/

smatch warnings:
drivers/pwm/core.c:1530 pwm_put() warn: variable dereferenced before check 'pwm' (see line 1528)

vim +/pwm +1530 drivers/pwm/core.c

8138d2ddbcca2a Thierry Reding   2012-03-26  1521  
8138d2ddbcca2a Thierry Reding   2012-03-26  1522  /**
8138d2ddbcca2a Thierry Reding   2012-03-26  1523   * pwm_put() - release a PWM device
8138d2ddbcca2a Thierry Reding   2012-03-26  1524   * @pwm: PWM device
8138d2ddbcca2a Thierry Reding   2012-03-26  1525   */
8138d2ddbcca2a Thierry Reding   2012-03-26  1526  void pwm_put(struct pwm_device *pwm)
8138d2ddbcca2a Thierry Reding   2012-03-26  1527  {
d60bc299573248 Uwe Kleine-König 2024-03-17 @1528  	struct pwm_chip *chip = pwm->chip;
d60bc299573248 Uwe Kleine-König 2024-03-17  1529  
8138d2ddbcca2a Thierry Reding   2012-03-26 @1530  	if (!pwm)
8138d2ddbcca2a Thierry Reding   2012-03-26  1531  		return;
8138d2ddbcca2a Thierry Reding   2012-03-26  1532  
8138d2ddbcca2a Thierry Reding   2012-03-26  1533  	mutex_lock(&pwm_lock);
8138d2ddbcca2a Thierry Reding   2012-03-26  1534  
8138d2ddbcca2a Thierry Reding   2012-03-26  1535  	if (!test_and_clear_bit(PWMF_REQUESTED, &pwm->flags)) {
e50d3523ff4564 Sachin Kamat     2012-08-10  1536  		pr_warn("PWM device already freed\n");
8138d2ddbcca2a Thierry Reding   2012-03-26  1537  		goto out;
8138d2ddbcca2a Thierry Reding   2012-03-26  1538  	}
8138d2ddbcca2a Thierry Reding   2012-03-26  1539  
d60bc299573248 Uwe Kleine-König 2024-03-17  1540  	if (chip->ops->free)
8138d2ddbcca2a Thierry Reding   2012-03-26  1541  		pwm->chip->ops->free(pwm->chip, pwm);
8138d2ddbcca2a Thierry Reding   2012-03-26  1542  
8138d2ddbcca2a Thierry Reding   2012-03-26  1543  	pwm->label = NULL;
8138d2ddbcca2a Thierry Reding   2012-03-26  1544  
d60bc299573248 Uwe Kleine-König 2024-03-17  1545  	put_device(&chip->dev);
d60bc299573248 Uwe Kleine-König 2024-03-17  1546  
d60bc299573248 Uwe Kleine-König 2024-03-17  1547  	module_put(chip->owner);
8138d2ddbcca2a Thierry Reding   2012-03-26  1548  out:
8138d2ddbcca2a Thierry Reding   2012-03-26  1549  	mutex_unlock(&pwm_lock);
8138d2ddbcca2a Thierry Reding   2012-03-26  1550  }
8138d2ddbcca2a Thierry Reding   2012-03-26  1551  EXPORT_SYMBOL_GPL(pwm_put);
8138d2ddbcca2a Thierry Reding   2012-03-26  1552  

:::::: The code at line 1530 was first introduced by commit
:::::: 8138d2ddbcca2a100482dac390133f83c5a60f94 pwm: Add table-based lookup for static mappings

:::::: TO: Thierry Reding <thierry.reding@avionic-design.de>
:::::: CC: Thierry Reding <thierry.reding@avionic-design.de>

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [linux-next:master 1128/2532] drivers/pwm/core.c:1530 pwm_put() warn: variable dereferenced before check 'pwm' (see line 1528)
@ 2024-04-02 14:13 Dan Carpenter
  2024-04-02 15:11 ` Uwe Kleine-König
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2024-04-02 14:13 UTC (permalink / raw)
  To: oe-kbuild, Uwe Kleine-König; +Cc: lkp, oe-kbuild-all

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   a6bd6c9333397f5a0e2667d4d82fef8c970108f2
commit: d60bc2995732489766cbe650fc367e036ff6a0e0 [1128/2532] pwm: Add a struct device to struct pwm_chip
config: m68k-randconfig-r071-20240326 (https://download.01.org/0day-ci/archive/20240331/202403312030.QYCgiAey-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 13.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202403312030.QYCgiAey-lkp@intel.com/

smatch warnings:
drivers/pwm/core.c:1530 pwm_put() warn: variable dereferenced before check 'pwm' (see line 1528)

vim +/pwm +1530 drivers/pwm/core.c

8138d2ddbcca2a Thierry Reding   2012-03-26  1526  void pwm_put(struct pwm_device *pwm)
8138d2ddbcca2a Thierry Reding   2012-03-26  1527  {
d60bc299573248 Uwe Kleine-König 2024-03-17 @1528  	struct pwm_chip *chip = pwm->chip;
                                                                                ^^^^^^^^^^
Dereference

d60bc299573248 Uwe Kleine-König 2024-03-17  1529  
8138d2ddbcca2a Thierry Reding   2012-03-26 @1530  	if (!pwm)
                                                            ^^^^
Too late.

8138d2ddbcca2a Thierry Reding   2012-03-26  1531  		return;
8138d2ddbcca2a Thierry Reding   2012-03-26  1532  
8138d2ddbcca2a Thierry Reding   2012-03-26  1533  	mutex_lock(&pwm_lock);

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [linux-next:master 1128/2532] drivers/pwm/core.c:1530 pwm_put() warn: variable dereferenced before check 'pwm' (see line 1528)
  2024-04-02 14:13 Dan Carpenter
@ 2024-04-02 15:11 ` Uwe Kleine-König
  2024-04-30 11:08   ` Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Uwe Kleine-König @ 2024-04-02 15:11 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: oe-kbuild, lkp, oe-kbuild-all

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

Hello,

On Tue, Apr 02, 2024 at 05:13:15PM +0300, Dan Carpenter wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> head:   a6bd6c9333397f5a0e2667d4d82fef8c970108f2
> commit: d60bc2995732489766cbe650fc367e036ff6a0e0 [1128/2532] pwm: Add a struct device to struct pwm_chip
> config: m68k-randconfig-r071-20240326 (https://download.01.org/0day-ci/archive/20240331/202403312030.QYCgiAey-lkp@intel.com/config)
> compiler: m68k-linux-gcc (GCC) 13.2.0
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> | Closes: https://lore.kernel.org/r/202403312030.QYCgiAey-lkp@intel.com/
> 
> smatch warnings:
> drivers/pwm/core.c:1530 pwm_put() warn: variable dereferenced before check 'pwm' (see line 1528)
> 
> vim +/pwm +1530 drivers/pwm/core.c
> 
> 8138d2ddbcca2a Thierry Reding   2012-03-26  1526  void pwm_put(struct pwm_device *pwm)
> 8138d2ddbcca2a Thierry Reding   2012-03-26  1527  {
> d60bc299573248 Uwe Kleine-König 2024-03-17 @1528  	struct pwm_chip *chip = pwm->chip;
>                                                                                 ^^^^^^^^^^
> Dereference
> 
> d60bc299573248 Uwe Kleine-König 2024-03-17  1529  
> 8138d2ddbcca2a Thierry Reding   2012-03-26 @1530  	if (!pwm)
>                                                             ^^^^
> Too late.
> 
> 8138d2ddbcca2a Thierry Reding   2012-03-26  1531  		return;
> 8138d2ddbcca2a Thierry Reding   2012-03-26  1532  
> 8138d2ddbcca2a Thierry Reding   2012-03-26  1533  	mutex_lock(&pwm_lock);

This is already addressed in fbf632f9dc55.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [linux-next:master 1128/2532] drivers/pwm/core.c:1530 pwm_put() warn: variable dereferenced before check 'pwm' (see line 1528)
  2024-04-02 15:11 ` Uwe Kleine-König
@ 2024-04-30 11:08   ` Dan Carpenter
  2024-04-30 16:59     ` Uwe Kleine-König
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2024-04-30 11:08 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: oe-kbuild, lkp, oe-kbuild-all

On Tue, Apr 02, 2024 at 05:11:22PM +0200, Uwe Kleine-König wrote:
> Hello,
> 
> > 8138d2ddbcca2a Thierry Reding   2012-03-26  1526  void pwm_put(struct pwm_device *pwm)
> > 8138d2ddbcca2a Thierry Reding   2012-03-26  1527  {
> > d60bc299573248 Uwe Kleine-König 2024-03-17 @1528  	struct pwm_chip *chip = pwm->chip;
> >                                                                                 ^^^^^^^^^^
> > Dereference
> > 
> > d60bc299573248 Uwe Kleine-König 2024-03-17  1529  
> > 8138d2ddbcca2a Thierry Reding   2012-03-26 @1530  	if (!pwm)
> >                                                             ^^^^
> > Too late.
> > 
> > 8138d2ddbcca2a Thierry Reding   2012-03-26  1531  		return;
> > 8138d2ddbcca2a Thierry Reding   2012-03-26  1532  
> > 8138d2ddbcca2a Thierry Reding   2012-03-26  1533  	mutex_lock(&pwm_lock);
> 
> This is already addressed in fbf632f9dc55.
> 

Apparently we never merged that commit, though...  It's not in
linux-next.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [linux-next:master 1128/2532] drivers/pwm/core.c:1530 pwm_put() warn: variable dereferenced before check 'pwm' (see line 1528)
  2024-04-30 11:08   ` Dan Carpenter
@ 2024-04-30 16:59     ` Uwe Kleine-König
  0 siblings, 0 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2024-04-30 16:59 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: oe-kbuild, lkp, oe-kbuild-all

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

Hello Dan,

On Tue, Apr 30, 2024 at 02:08:05PM +0300, Dan Carpenter wrote:
> On Tue, Apr 02, 2024 at 05:11:22PM +0200, Uwe Kleine-König wrote:
> > Hello,
> > 
> > > 8138d2ddbcca2a Thierry Reding   2012-03-26  1526  void pwm_put(struct pwm_device *pwm)
> > > 8138d2ddbcca2a Thierry Reding   2012-03-26  1527  {
> > > d60bc299573248 Uwe Kleine-König 2024-03-17 @1528  	struct pwm_chip *chip = pwm->chip;
> > >                                                                                 ^^^^^^^^^^
> > > Dereference
> > > 
> > > d60bc299573248 Uwe Kleine-König 2024-03-17  1529  
> > > 8138d2ddbcca2a Thierry Reding   2012-03-26 @1530  	if (!pwm)
> > >                                                             ^^^^
> > > Too late.
> > > 
> > > 8138d2ddbcca2a Thierry Reding   2012-03-26  1531  		return;
> > > 8138d2ddbcca2a Thierry Reding   2012-03-26  1532  
> > > 8138d2ddbcca2a Thierry Reding   2012-03-26  1533  	mutex_lock(&pwm_lock);
> > 
> > This is already addressed in fbf632f9dc55.
> > 
> 
> Apparently we never merged that commit, though...  It's not in
> linux-next.

Oh, I recently dropped a few commits from my for-next branch and this
one was (wrongly) among them. Thanks for paying attention, it's back
now.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-04-30 16:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-31 12:48 [linux-next:master 1128/2532] drivers/pwm/core.c:1530 pwm_put() warn: variable dereferenced before check 'pwm' (see line 1528) kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2024-04-02 14:13 Dan Carpenter
2024-04-02 15:11 ` Uwe Kleine-König
2024-04-30 11:08   ` Dan Carpenter
2024-04-30 16:59     ` Uwe Kleine-König

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.