The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: oe-kbuild@lists.linux.dev,
	Charles Keepax <ckeepax@opensource.cirrus.com>
Cc: lkp@intel.com, oe-kbuild-all@lists.linux.dev,
	linux-kernel@vger.kernel.org, Vinod Koul <vkoul@kernel.org>,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
Subject: drivers/soundwire/bus_type.c:108 sdw_drv_probe() error: Calling ida_alloc_max() with a 'max' argument which is a power of 2. -1 missing?
Date: Mon, 15 Dec 2025 11:55:57 +0300	[thread overview]
Message-ID: <202512131339.LMMvaF5G-lkp@intel.com> (raw)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   9551a26f17d9445eed497bd7c639d48dfc3c0af4
commit: aab12022b076f0b385b7a9a78e1161bd2df5d1e3 soundwire: bus: Add internal slave ID and use for IRQs
date:   7 months ago
config: i386-randconfig-r073-20251212 (https://download.01.org/0day-ci/archive/20251213/202512131339.LMMvaF5G-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.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/202512131339.LMMvaF5G-lkp@intel.com/

smatch warnings:
drivers/soundwire/bus_type.c:108 sdw_drv_probe() error: Calling ida_alloc_max() with a 'max' argument which is a power of 2. -1 missing?

vim +/max +108 drivers/soundwire/bus_type.c

9251345dca24b6 Vinod Koul           2017-12-14   81  static int sdw_drv_probe(struct device *dev)
9251345dca24b6 Vinod Koul           2017-12-14   82  {
9251345dca24b6 Vinod Koul           2017-12-14   83  	struct sdw_slave *slave = dev_to_sdw_dev(dev);
9251345dca24b6 Vinod Koul           2017-12-14   84  	struct sdw_driver *drv = drv_to_sdw_driver(dev->driver);
9251345dca24b6 Vinod Koul           2017-12-14   85  	const struct sdw_device_id *id;
9251345dca24b6 Vinod Koul           2017-12-14   86  	int ret;
9251345dca24b6 Vinod Koul           2017-12-14   87  
fcb9d730be1d30 Srinivas Kandagatla  2020-09-24   88  	/*
fcb9d730be1d30 Srinivas Kandagatla  2020-09-24   89  	 * fw description is mandatory to bind
fcb9d730be1d30 Srinivas Kandagatla  2020-09-24   90  	 */
fcb9d730be1d30 Srinivas Kandagatla  2020-09-24   91  	if (!dev->fwnode)
fcb9d730be1d30 Srinivas Kandagatla  2020-09-24   92  		return -ENODEV;
fcb9d730be1d30 Srinivas Kandagatla  2020-09-24   93  
fcb9d730be1d30 Srinivas Kandagatla  2020-09-24   94  	if (!IS_ENABLED(CONFIG_ACPI) && !dev->of_node)
fcb9d730be1d30 Srinivas Kandagatla  2020-09-24   95  		return -ENODEV;
fcb9d730be1d30 Srinivas Kandagatla  2020-09-24   96  
9251345dca24b6 Vinod Koul           2017-12-14   97  	id = sdw_get_device_id(slave, drv);
9251345dca24b6 Vinod Koul           2017-12-14   98  	if (!id)
9251345dca24b6 Vinod Koul           2017-12-14   99  		return -ENODEV;
9251345dca24b6 Vinod Koul           2017-12-14  100  
9251345dca24b6 Vinod Koul           2017-12-14  101  	/*
9251345dca24b6 Vinod Koul           2017-12-14  102  	 * attach to power domain but don't turn on (last arg)
9251345dca24b6 Vinod Koul           2017-12-14  103  	 */
9251345dca24b6 Vinod Koul           2017-12-14  104  	ret = dev_pm_domain_attach(dev, false);
29ffcc88f2065f Ulf Hansson          2018-04-26  105  	if (ret)
29ffcc88f2065f Ulf Hansson          2018-04-26  106  		return ret;
29ffcc88f2065f Ulf Hansson          2018-04-26  107  
aab12022b076f0 Charles Keepax       2025-04-29 @108  	ret = ida_alloc_max(&slave->bus->slave_ida, SDW_FW_MAX_DEVICES, GFP_KERNEL);

The SDW_FW_MAX_DEVICES macro is used here and also in sdw_irq_create().

	bus->domain = irq_domain_create_linear(fwnode, SDW_FW_MAX_DEVICES, ...

The ida_alloc_max() function an inclusive max so probably this should be
"SDW_FW_MAX_DEVICES - 1".

aab12022b076f0 Charles Keepax       2025-04-29  109  	if (ret < 0) {
aab12022b076f0 Charles Keepax       2025-04-29  110  		dev_err(dev, "Failed to allocated ID: %d\n", ret);
aab12022b076f0 Charles Keepax       2025-04-29  111  		return ret;
aab12022b076f0 Charles Keepax       2025-04-29  112  	}
aab12022b076f0 Charles Keepax       2025-04-29  113  	slave->index = ret;
aab12022b076f0 Charles Keepax       2025-04-29  114  
9251345dca24b6 Vinod Koul           2017-12-14  115  	ret = drv->probe(slave, id);
9251345dca24b6 Vinod Koul           2017-12-14  116  	if (ret) {
9251345dca24b6 Vinod Koul           2017-12-14  117  		dev_pm_domain_detach(dev, false);
aab12022b076f0 Charles Keepax       2025-04-29  118  		ida_free(&slave->bus->slave_ida, slave->index);

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


                 reply	other threads:[~2025-12-15  8:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=202512131339.LMMvaF5G-lkp@intel.com \
    --to=dan.carpenter@linaro.org \
    --cc=ckeepax@opensource.cirrus.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=oe-kbuild@lists.linux.dev \
    --cc=pierre-louis.bossart@linux.dev \
    --cc=vkoul@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox