linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guru Das Srinagesh <quic_gurus@quicinc.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: <swboyd@chromium.org>, <linux-arm-msm@vger.kernel.org>
Subject: Re: [bug report] firmware: qcom_scm: Make __qcom_scm_is_call_available() return bool
Date: Mon, 11 Oct 2021 11:40:22 -0700	[thread overview]
Message-ID: <20211011184022.GA18698@hu-gurus-sd.qualcomm.com> (raw)
In-Reply-To: <20211011092054.GA6793@kili>

On Mon, Oct 11, 2021 at 12:20:54PM +0300, Dan Carpenter wrote:
> Hello Stephen Boyd,
> 
> The patch 9d11af8b06a8: "firmware: qcom_scm: Make
> __qcom_scm_is_call_available() return bool" from Feb 23, 2021, leads
> to the following Smatch static checker warning:
> 
> 	drivers/firmware/qcom_scm.c:255 __qcom_scm_is_call_available()
> 	warn: signedness bug returning '(-22)'
> 
> drivers/firmware/qcom_scm.c
>     232 static bool __qcom_scm_is_call_available(struct device *dev, u32 svc_id,
>     233                                          u32 cmd_id)
>     234 {
>     235         int ret;
>     236         struct qcom_scm_desc desc = {
>     237                 .svc = QCOM_SCM_SVC_INFO,
>     238                 .cmd = QCOM_SCM_INFO_IS_CALL_AVAIL,
>     239                 .owner = ARM_SMCCC_OWNER_SIP,
>     240         };
>     241         struct qcom_scm_res res;
>     242 
>     243         desc.arginfo = QCOM_SCM_ARGS(1);
>     244         switch (__get_convention()) {
>     245         case SMC_CONVENTION_ARM_32:
>     246         case SMC_CONVENTION_ARM_64:
>     247                 desc.args[0] = SCM_SMC_FNID(svc_id, cmd_id) |
>     248                                 (ARM_SMCCC_OWNER_SIP << ARM_SMCCC_OWNER_SHIFT);
>     249                 break;
>     250         case SMC_CONVENTION_LEGACY:
>     251                 desc.args[0] = SCM_LEGACY_FNID(svc_id, cmd_id);
>     252                 break;
>     253         default:
>     254                 pr_err("Unknown SMC convention being used\n");
> --> 255                 return -EINVAL;
> 
> Presumably this should be "return false;"?
> 
>     256         }
>     257 
>     258         ret = qcom_scm_call(dev, &desc, &res);
>     259 
>     260         return ret ? false : !!res.result[0];
>     261 }
> 
> regards,
> dan carpenter

Hi Dan, Stephen,

Please find the fix below:


From 8bbdb1517c3f58b6b29d0915424b9b0e03752e14 Mon Sep 17 00:00:00 2001
From: Guru Das Srinagesh <quic_gurus@quicinc.com>
Date: Mon, 11 Oct 2021 11:18:06 -0700
Subject: [PATCH] firmware: qcom_scm: Fix error retval in
 __qcom_scm_is_call_available()

Since __qcom_scm_is_call_available() returns bool, have it return false
instead of -EINVAL if an invalid SMC convention is detected.

This fixes the Smatch static checker warning:

	drivers/firmware/qcom_scm.c:255 __qcom_scm_is_call_available()
	warn: signedness bug returning '(-22)'

Fixes: 9d11af8b06a8 ("firmware: qcom_scm: Make __qcom_scm_is_call_available() return bool")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Guru Das Srinagesh <quic_gurus@quicinc.com>
---
 drivers/firmware/qcom_scm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
index 2ee97ba..27a64de 100644
--- a/drivers/firmware/qcom_scm.c
+++ b/drivers/firmware/qcom_scm.c
@@ -252,7 +252,7 @@ static bool __qcom_scm_is_call_available(struct device *dev, u32 svc_id,
 		break;
 	default:
 		pr_err("Unknown SMC convention being used\n");
-		return -EINVAL;
+		return false;
 	}
 
 	ret = qcom_scm_call(dev, &desc, &res);
-- 
2.7.4


Thank you.

Guru Das.

  reply	other threads:[~2021-10-11 18:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-11  9:20 [bug report] firmware: qcom_scm: Make __qcom_scm_is_call_available() return bool Dan Carpenter
2021-10-11 18:40 ` Guru Das Srinagesh [this message]
2021-10-11 19:06   ` Stephen Boyd
2021-10-11 20:10     ` Guru Das Srinagesh

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=20211011184022.GA18698@hu-gurus-sd.qualcomm.com \
    --to=quic_gurus@quicinc.com \
    --cc=dan.carpenter@oracle.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=swboyd@chromium.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;
as well as URLs for NNTP newsgroup(s).