All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org, Ricardo Rivera-Matos <r-rivera-matos@ti.com>
Cc: lkp@intel.com, kbuild-all@lists.01.org,
	Linux Memory Management List <linux-mm@kvack.org>,
	Sebastian Reichel <sre@kernel.org>
Subject: [linux-next:master 1548/11541] drivers/power/supply/bq256xx_charger.c:1512 bq256xx_hw_init() error: buffer overflow 'bq256xx_watchdog_time' 8 <= 8
Date: Tue, 16 Feb 2021 12:16:26 +0300	[thread overview]
Message-ID: <20210216091626.GW2087@kadam> (raw)

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

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   52a0bcb60e40f30211cb5cbbb0f582ec4e91d896
commit: 32e4978bb920d047fe5de3ea42d176f267c01f63 [1548/11541] power: supply: bq256xx: Introduce the BQ256XX charger driver
config: x86_64-randconfig-m001-20210215 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/power/supply/bq256xx_charger.c:1512 bq256xx_hw_init() error: buffer overflow 'bq256xx_watchdog_time' 8 <= 8

vim +/bq256xx_watchdog_time +1512 drivers/power/supply/bq256xx_charger.c

32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1503  static int bq256xx_hw_init(struct bq256xx_device *bq)
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1504  {
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1505  	struct power_supply_battery_info bat_info = { };
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1506  	int wd_reg_val = BQ256XX_WATCHDOG_DIS;
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1507  	int ret = 0;
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1508  	int i;
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1509  
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1510  	for (i = 0; i < BQ256XX_NUM_WD_VAL; i++) {
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1511  		if (bq->watchdog_timer > bq256xx_watchdog_time[i] &&
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06 @1512  		    bq->watchdog_timer < bq256xx_watchdog_time[i + 1])
                                                                                                               ^^^^^
The static checker is worried about that "i + 1" can be
== BQ256XX_NUM_WD_VAL.  Potentially the bq256xx_watchdog_time[] is
too high so this is impossible?

32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1513  			wd_reg_val = i;
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1514  	}
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1515  	ret = regmap_update_bits(bq->regmap, BQ256XX_CHARGER_CONTROL_1,
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1516  				 BQ256XX_WATCHDOG_MASK, wd_reg_val <<
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1517  						BQ256XX_WDT_BIT_SHIFT);

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 30996 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org
Subject: [linux-next:master 1548/11541] drivers/power/supply/bq256xx_charger.c:1512 bq256xx_hw_init() error: buffer overflow 'bq256xx_watchdog_time' 8 <= 8
Date: Tue, 16 Feb 2021 12:16:26 +0300	[thread overview]
Message-ID: <20210216091626.GW2087@kadam> (raw)

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

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   52a0bcb60e40f30211cb5cbbb0f582ec4e91d896
commit: 32e4978bb920d047fe5de3ea42d176f267c01f63 [1548/11541] power: supply: bq256xx: Introduce the BQ256XX charger driver
config: x86_64-randconfig-m001-20210215 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/power/supply/bq256xx_charger.c:1512 bq256xx_hw_init() error: buffer overflow 'bq256xx_watchdog_time' 8 <= 8

vim +/bq256xx_watchdog_time +1512 drivers/power/supply/bq256xx_charger.c

32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1503  static int bq256xx_hw_init(struct bq256xx_device *bq)
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1504  {
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1505  	struct power_supply_battery_info bat_info = { };
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1506  	int wd_reg_val = BQ256XX_WATCHDOG_DIS;
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1507  	int ret = 0;
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1508  	int i;
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1509  
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1510  	for (i = 0; i < BQ256XX_NUM_WD_VAL; i++) {
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1511  		if (bq->watchdog_timer > bq256xx_watchdog_time[i] &&
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06 @1512  		    bq->watchdog_timer < bq256xx_watchdog_time[i + 1])
                                                                                                               ^^^^^
The static checker is worried about that "i + 1" can be
== BQ256XX_NUM_WD_VAL.  Potentially the bq256xx_watchdog_time[] is
too high so this is impossible?

32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1513  			wd_reg_val = i;
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1514  	}
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1515  	ret = regmap_update_bits(bq->regmap, BQ256XX_CHARGER_CONTROL_1,
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1516  				 BQ256XX_WATCHDOG_MASK, wd_reg_val <<
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1517  						BQ256XX_WDT_BIT_SHIFT);

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 30996 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild-all@lists.01.org
Subject: [linux-next:master 1548/11541] drivers/power/supply/bq256xx_charger.c:1512 bq256xx_hw_init() error: buffer overflow 'bq256xx_watchdog_time' 8 <= 8
Date: Tue, 16 Feb 2021 12:16:26 +0300	[thread overview]
Message-ID: <20210216091626.GW2087@kadam> (raw)

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

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   52a0bcb60e40f30211cb5cbbb0f582ec4e91d896
commit: 32e4978bb920d047fe5de3ea42d176f267c01f63 [1548/11541] power: supply: bq256xx: Introduce the BQ256XX charger driver
config: x86_64-randconfig-m001-20210215 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/power/supply/bq256xx_charger.c:1512 bq256xx_hw_init() error: buffer overflow 'bq256xx_watchdog_time' 8 <= 8

vim +/bq256xx_watchdog_time +1512 drivers/power/supply/bq256xx_charger.c

32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1503  static int bq256xx_hw_init(struct bq256xx_device *bq)
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1504  {
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1505  	struct power_supply_battery_info bat_info = { };
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1506  	int wd_reg_val = BQ256XX_WATCHDOG_DIS;
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1507  	int ret = 0;
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1508  	int i;
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1509  
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1510  	for (i = 0; i < BQ256XX_NUM_WD_VAL; i++) {
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1511  		if (bq->watchdog_timer > bq256xx_watchdog_time[i] &&
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06 @1512  		    bq->watchdog_timer < bq256xx_watchdog_time[i + 1])
                                                                                                               ^^^^^
The static checker is worried about that "i + 1" can be
== BQ256XX_NUM_WD_VAL.  Potentially the bq256xx_watchdog_time[] is
too high so this is impossible?

32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1513  			wd_reg_val = i;
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1514  	}
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1515  	ret = regmap_update_bits(bq->regmap, BQ256XX_CHARGER_CONTROL_1,
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1516  				 BQ256XX_WATCHDOG_MASK, wd_reg_val <<
32e4978bb920d0 Ricardo Rivera-Matos 2021-01-06  1517  						BQ256XX_WDT_BIT_SHIFT);

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 30996 bytes --]

             reply	other threads:[~2021-02-16  9:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-16  9:16 Dan Carpenter [this message]
2021-02-16  9:16 ` [linux-next:master 1548/11541] drivers/power/supply/bq256xx_charger.c:1512 bq256xx_hw_init() error: buffer overflow 'bq256xx_watchdog_time' 8 <= 8 Dan Carpenter
2021-02-16  9:16 ` Dan Carpenter
  -- strict thread matches above, loose matches on Subject: below --
2021-02-15 21:07 kernel test robot

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=20210216091626.GW2087@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=kbuild-all@lists.01.org \
    --cc=kbuild@lists.01.org \
    --cc=linux-mm@kvack.org \
    --cc=lkp@intel.com \
    --cc=r-rivera-matos@ti.com \
    --cc=sre@kernel.org \
    /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.