All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Kory Maincent <kory.maincent@bootlin.com>
Cc: kernel-janitors@vger.kernel.org
Subject: [bug report] net: pse-pd: Avoid setting max_uA in regulator constraints
Date: Tue, 23 Sep 2025 14:21:03 +0300	[thread overview]
Message-ID: <aNKCn90htSbZHVsn@stanley.mountain> (raw)

Hello Kory Maincent,

Commit 675d0e3cacc3 ("net: pse-pd: Avoid setting max_uA in regulator
constraints") from Jan 10, 2025 (linux-next), leads to the following
Smatch static checker warning:

	drivers/net/pse-pd/pse_core.c:810 pse_pi_set_current_limit()
	warn: AAA no lower bound on 'max_uA' rl='s32min-(-1),1-1920000'

drivers/net/pse-pd/pse_core.c
    783 static int pse_pi_set_current_limit(struct regulator_dev *rdev, int min_uA,
    784                                     int max_uA)
    785 {
    786         struct pse_controller_dev *pcdev = rdev_get_drvdata(rdev);
    787         const struct pse_controller_ops *ops;
    788         int id, mW, ret;
    789         s64 tmp_64;
    790 
    791         ops = pcdev->ops;
    792         if (!ops->pi_set_pw_limit || !ops->pi_get_voltage)
    793                 return -EOPNOTSUPP;
    794 
    795         if (max_uA > MAX_PI_CURRENT)

Do we need this?  Shouldn't it be checked in regulator_check_current_limit()
instead?  max_uA is an int.  Do we need to check for negatives?

    796                 return -ERANGE;
    797 
    798         id = rdev_get_id(rdev);
    799         mutex_lock(&pcdev->lock);
    800         ret = _pse_pi_get_voltage(rdev);
    801         if (!ret) {
    802                 dev_err(pcdev->dev, "Voltage null\n");
    803                 ret = -ERANGE;
    804                 goto out;
    805         }
    806         if (ret < 0)
    807                 goto out;
    808 
    809         tmp_64 = ret;
--> 810         tmp_64 *= max_uA;
    811         /* mW = uA * uV / 1000000000 */
    812         mW = DIV_ROUND_CLOSEST_ULL(tmp_64, 1000000000);
    813         ret = ops->pi_set_pw_limit(pcdev, id, mW);
    814 out:
    815         mutex_unlock(&pcdev->lock);
    816 
    817         return ret;
    818 }

regards,
dan carpenter

             reply	other threads:[~2025-09-23 11:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-23 11:21 Dan Carpenter [this message]
2025-09-23 12:56 ` [bug report] net: pse-pd: Avoid setting max_uA in regulator constraints Kory Maincent

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=aNKCn90htSbZHVsn@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kory.maincent@bootlin.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 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.