public inbox for platform-driver-x86@vger.kernel.org
 help / color / mirror / Atom feed
From: Jia-Ju Bai <baijiaju1990@gmail.com>
To: Hans de Goede <hdegoede@redhat.com>, markgross@kernel.org
Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] platform: x86: huawei-wmi: check the return value of device_create_file()
Date: Thu, 3 Mar 2022 09:45:48 +0800	[thread overview]
Message-ID: <bd3a5715-bb6c-2e2f-7de9-5bc719b13c15@gmail.com> (raw)
In-Reply-To: <54dafc1d-bc72-8cb0-a539-4fdfc068cb5a@redhat.com>

Hi Hans,

Thanks for the advice!
I will send a V2 patch.


Best wishes,
Jia-Ju Bai


On 2022/3/2 22:31, Hans de Goede wrote:
> Hi,
>
> On 2/25/22 14:04, 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>
> Please run check-patch.pl your patches before submitting them.
>
>
>> ---
>>   drivers/platform/x86/huawei-wmi.c | 15 ++++++++++++---
>>   1 file changed, 12 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/platform/x86/huawei-wmi.c b/drivers/platform/x86/huawei-wmi.c
>> index a2d846c4a7ee..2ffd3840f3e8 100644
>> --- a/drivers/platform/x86/huawei-wmi.c
>> +++ b/drivers/platform/x86/huawei-wmi.c
>> @@ -470,10 +470,19 @@ 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;
> There needs to be an empty line here,
>> +	err = device_create_file(&battery->dev,
>> +						&dev_attr_charge_control_start_threshold);
> Why the weird continuation of the call on another line? Please make this a single line.
>
>> +	if (err)
>> +		return err;
> Empty line here.
>
>> +	err = device_create_file(&battery->dev,
>> +						&dev_attr_charge_control_end_threshold);
> Please make this a single line.
>
>> +	if (err) {
>> +		device_remove_file(&battery->dev,
>> +						&dev_attr_charge_control_start_threshold);
>> +	}
> No need for {} here.
>
>>   
>> -	return 0;
>> +	return err;
>>   }
>>   
>>   static int huawei_wmi_battery_remove(struct power_supply *battery)
> Regards,
>
> Hans
>


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

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-25 13:04 [PATCH] platform: x86: huawei-wmi: check the return value of device_create_file() Jia-Ju Bai
2022-03-02 14:31 ` Hans de Goede
2022-03-03  1:45   ` Jia-Ju Bai [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=bd3a5715-bb6c-2e2f-7de9-5bc719b13c15@gmail.com \
    --to=baijiaju1990@gmail.com \
    --cc=hdegoede@redhat.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