From: Dan Carpenter <dan.carpenter@linaro.org>
To: Hao Chang <ot_chhao.chang@mediatek.com>
Cc: linux-mediatek@lists.infradead.org, linux-gpio@vger.kernel.org
Subject: [bug report] pinctrl: mediatek: Add EINT support for multiple addresses
Date: Tue, 25 Mar 2025 08:45:13 +0300 [thread overview]
Message-ID: <dac846e5-d15d-4def-a7e3-ce17e74e2da6@stanley.mountain> (raw)
Hello Hao Chang,
Commit 3ef9f710efcb ("pinctrl: mediatek: Add EINT support for
multiple addresses") from Mar 22, 2025 (linux-next), leads to the
following Smatch static checker warning:
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c:384 mtk_build_eint()
warn: error code type promoted to positive: 'count_reg_names'
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
374 return 0;
375
376 if (!of_property_read_bool(np, "interrupt-controller"))
377 return -ENODEV;
378
379 hw->eint = devm_kzalloc(hw->dev, sizeof(*hw->eint), GFP_KERNEL);
380 if (!hw->eint)
381 return -ENOMEM;
382
383 count_reg_names = of_property_count_strings(np, "reg-names");
--> 384 if (count_reg_names < hw->soc->nbase_names)
count_reg_names is type int but hw->soc->nbase_names is unsigned int. So
if of_property_count_strings() returns a negative error code then it's
type promoted as a high positive unsigned int value and treated as success.
385 return -EINVAL;
386
387 hw->eint->nbase = count_reg_names - hw->soc->nbase_names;
hw->eint->nbase is a u8 so the negative value is truncated to a low positive
value.
388 hw->eint->base = devm_kmalloc_array(&pdev->dev, hw->eint->nbase,
389 sizeof(*hw->eint->base), GFP_KERNEL | __GFP_ZERO);
This allocation will always succeed.
regards,
dan carpenter
390 if (!hw->eint->base) {
391 ret = -ENOMEM;
392 goto err_free_base;
393 }
394
395 for (i = hw->soc->nbase_names, j = 0; i < count_reg_names; i++, j++) {
396 hw->eint->base[j] = of_iomap(np, i);
397 if (IS_ERR(hw->eint->base[j])) {
398 ret = PTR_ERR(hw->eint->base[j]);
399 goto err_free_eint;
400 }
401 }
402
next reply other threads:[~2025-03-25 5:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-25 5:45 Dan Carpenter [this message]
2025-03-25 5:47 ` [bug report] pinctrl: mediatek: Add EINT support for multiple addresses Dan Carpenter
2025-03-26 3:11 ` Chhao Chang (常浩)
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=dac846e5-d15d-4def-a7e3-ce17e74e2da6@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=ot_chhao.chang@mediatek.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;
as well as URLs for NNTP newsgroup(s).