mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Jia-Ju Bai <baijiaju1990@gmail.com>, markgross@kernel.org
Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] platform: x86: huawei-wmi: check the return value of device_create_file()
Date: Tue, 8 Mar 2022 15:44:51 +0100	[thread overview]
Message-ID: <0739f2f1-8c46-5fb2-2e1e-070a41eabc1d@redhat.com> (raw)
In-Reply-To: <20220303022421.313-1-baijiaju1990@gmail.com>

Hi,

On 3/3/22 03:24, Jia-Ju Bai wrote:
> The function device_create_file() in huawei_wmi_battery_add() can fail,
> so its return value should be checked.
> 
> Fixes: 355a070b09ab ("platform/x86: huawei-wmi: Add battery charging thresholds")
> Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
> ---
> v2:
> * Fix the code format.
>   Thank Hans for good advice.

Thank you for your patch, I've applied this patch to my review-hans 
branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my
local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be
added to the platform-drivers-x86/for-next branch and eventually
will be included in the pdx86 pull-request to Linus for the next
merge-window.

Regards,

Hans


> 
> ---
>  drivers/platform/x86/huawei-wmi.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/platform/x86/huawei-wmi.c b/drivers/platform/x86/huawei-wmi.c
> index a2d846c4a7ee..eac3e6b4ea11 100644
> --- a/drivers/platform/x86/huawei-wmi.c
> +++ b/drivers/platform/x86/huawei-wmi.c
> @@ -470,10 +470,17 @@ static DEVICE_ATTR_RW(charge_control_thresholds);
>  
>  static int huawei_wmi_battery_add(struct power_supply *battery)
>  {
> -	device_create_file(&battery->dev, &dev_attr_charge_control_start_threshold);
> -	device_create_file(&battery->dev, &dev_attr_charge_control_end_threshold);
> +	int err = 0;
>  
> -	return 0;
> +	err = device_create_file(&battery->dev, &dev_attr_charge_control_start_threshold);
> +	if (err)
> +		return err;
> +
> +	err = device_create_file(&battery->dev, &dev_attr_charge_control_end_threshold);
> +	if (err)
> +		device_remove_file(&battery->dev, &dev_attr_charge_control_start_threshold);
> +
> +	return err;
>  }
>  
>  static int huawei_wmi_battery_remove(struct power_supply *battery)


      reply	other threads:[~2022-03-08 14:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-03  2:24 Jia-Ju Bai
2022-03-08 14:44 ` Hans de Goede [this message]

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=0739f2f1-8c46-5fb2-2e1e-070a41eabc1d@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=baijiaju1990@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markgross@kernel.org \
    --cc=platform-driver-x86@vger.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

all inboxes | Powered by JetHome®