From: Maximilian Luz <luzmaximilian@gmail.com>
To: Hans de Goede <hdegoede@redhat.com>, kernel test robot <lkp@intel.com>
Cc: kbuild-all@lists.01.org, linux-kernel@vger.kernel.org,
Andy Shevchenko <andy.shevchenko@gmail.com>
Subject: Re: drivers/platform/surface/surface3-wmi.c:60:14: warning: variable 'status' set but not used
Date: Mon, 4 Jan 2021 16:24:54 +0100 [thread overview]
Message-ID: <1a749e41-86da-8607-ec39-c91cf4107a9f@gmail.com> (raw)
In-Reply-To: <184b4ec6-65f1-5a22-487b-20cc0fb1b587@redhat.com>
On 1/4/21 3:52 PM, Hans de Goede wrote:
> Hi,
>
> On 12/29/20 4:58 AM, kernel test robot wrote:
>> Hi Maximilian,
>>
>> FYI, the error/warning still remains.
>>
>> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
>> head: dea8dcf2a9fa8cc540136a6cd885c3beece16ec3
>> commit: f23027ca3d48b6f93c5994069fb25b73539fdf34 platform/surface: Move Surface 3 WMI driver to platform/surface
>> date: 9 weeks ago
>> config: x86_64-randconfig-r001-20201221 (attached as .config)
>> compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
>> reproduce (this is a W=1 build):
>> # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f23027ca3d48b6f93c5994069fb25b73539fdf34
>> git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
>> git fetch --no-tags linus master
>> git checkout f23027ca3d48b6f93c5994069fb25b73539fdf34
>> # save the attached .config to linux build tree
>> make W=1 ARCH=x86_64
>>
>> If you fix the issue, kindly add following tag as appropriate
>> Reported-by: kernel test robot <lkp@intel.com>
>>
>> All warnings (new ones prefixed by >>):
>>
>> drivers/platform/surface/surface3-wmi.c: In function 's3_wmi_query_block':
>>>> drivers/platform/surface/surface3-wmi.c:60:14: warning: variable 'status' set but not used [-Wunused-but-set-variable]
>> 60 | acpi_status status;
>> | ^~~~~~
>
> I guess fixing this would require something like this:
>
> From: Hans de Goede <hdegoede@redhat.com>
> Subject: [PATCH] platform/surface: surface3-wmi: Fix variable 'status' set but not used compiler warning
>
> Explictly check the status rather then relying on output.pointer staying
> NULL on an error. This silences the following compiler warning:
>
> drivers/platform/surface/surface3-wmi.c:60:14: warning: variable 'status' set but not used [-Wunused-but-set-variable]
>
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> drivers/platform/surface/surface3-wmi.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/platform/surface/surface3-wmi.c b/drivers/platform/surface/surface3-wmi.c
> index 130b6f52a600..4b7f79c0b78e 100644
> --- a/drivers/platform/surface/surface3-wmi.c
> +++ b/drivers/platform/surface/surface3-wmi.c
> @@ -63,6 +63,10 @@ static int s3_wmi_query_block(const char *guid, int instance, int *ret)
>
> mutex_lock(&s3_wmi_lock);
> status = wmi_query_block(guid, instance, &output);
> + if (ACPI_FAILURE(status)) {
> + error = -EIO;
> + goto out_free_unlock;
> + }
>
> obj = output.pointer;
>
>
> Maximilian, can you review and/or test this fix please ?
Ah, this was on my TODO list (among looking at some other things in this
driver), sorry that I haven't gotten to it yet. I'd have proposed pretty
much the exact same thing.
One thing to note though: You should initialize obj with NULL. Keeping
it uninitialized may mess with kfree() under out_free_unlock.
Unfortunately I don't have access to a Surface 3 to test, but apart from
not initializing obj, this patch looks good to me. You may add my
reviewed-by tag once you've fixed that.
Also note that drivers/platform/x86/msi-wmi.c suffers from the same
problem in msi_wmi_query_block() and should receive a similar fix.
Regards,
Max
next prev parent reply other threads:[~2021-01-04 15:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-29 3:58 drivers/platform/surface/surface3-wmi.c:60:14: warning: variable 'status' set but not used kernel test robot
2021-01-04 14:52 ` Hans de Goede
2021-01-04 15:24 ` Maximilian Luz [this message]
2021-02-04 11:36 ` Hans de Goede
2021-02-04 15:10 ` Maximilian Luz
-- strict thread matches above, loose matches on Subject: below --
2021-02-09 1:52 kernel test robot
2021-02-09 10:12 ` Hans de Goede
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=1a749e41-86da-8607-ec39-c91cf4107a9f@gmail.com \
--to=luzmaximilian@gmail.com \
--cc=andy.shevchenko@gmail.com \
--cc=hdegoede@redhat.com \
--cc=kbuild-all@lists.01.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.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