Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp376512pxm; Wed, 2 Mar 2022 17:45:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJzdPv9Dd5LNDVjo0Ey9UOD/YONuPgTsTmRrwE//bRPnhBCWlIHbhxgGGdJQTR6hAvcBypXd X-Received: by 2002:a63:2b05:0:b0:37c:43ce:1cdc with SMTP id r5-20020a632b05000000b0037c43ce1cdcmr3202724pgr.584.1646271959166; Wed, 02 Mar 2022 17:45:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646271959; cv=none; d=google.com; s=arc-20160816; b=F20eCcG1jxU6JFaPh7CslHnVs4GoYLutgnkU42JI5F1Z+l+RgzKBz6IMbI1dhmC2CZ l5Bs44KRzu6acS4vxt+C1xqRbWUF6N+6oFG/wX3sea0H+WcrixSnZ8UYuP6RSbwjWCnG IY2YlA0Y4pUfLgzLz8c0Kj6ViciN81okAOSb6UyyljcdT45DtHAnPF+f6FR+DIzTv2VD 1TC23q/KAOnd3Ym2LmTvbo7h3THk7ZFH3//ulNyiE+J5lghG21/F6butsW+OjtrrfQ40 hUhuqllHXAHyViWLs4BC3F0/YO1I3dE8EyejbDEb9jrOjd5ToGQ2Q6sqDRBjHEmaBmej ZjWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=MVq/KO9mQWlEmONgPovYPC/moYBrzhnqRKihrSUsxEo=; b=molTT1kfgHAyPLNwyHCt3ZCadgaYjDRR5LUDGMrdg4ZGVI6OPLYu4OzHpZTDfwJoao ChNWMka6QYOi76yMPUggbXg7D7HX24b7X/aWdhCJJbr5/YNNEkulqbv6sPt5l6MjM/vi 3dk271WYAG9V6LZqe0bzfVsaScUco1tFvoMvc4sghcTfc3qTXucP/7SSSx9AQs/1hiYN YnpRVa2z82MRsgsDgYXsIyNZzFOh0kmaX5pTcIAlwCOZt19JdVBVaOVIQ4jjsInjZ8fQ +yGW/4fsZw2KG/j6y8PzZrq3gdV/8VX3MX6dLz4UtxsAMUrYADLW2Qa2eHx/eo681wrV EOsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hT2Fv8FE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id my1-20020a17090b4c8100b001befc37f0c2si3343822pjb.37.2022.03.02.17.45.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 17:45:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hT2Fv8FE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BAB0F1B6E16; Wed, 2 Mar 2022 17:45:56 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231467AbiCCBqh (ORCPT + 99 others); Wed, 2 Mar 2022 20:46:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231445AbiCCBqg (ORCPT ); Wed, 2 Mar 2022 20:46:36 -0500 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A52921B6E05; Wed, 2 Mar 2022 17:45:51 -0800 (PST) Received: by mail-pg1-x531.google.com with SMTP id 195so3203265pgc.6; Wed, 02 Mar 2022 17:45:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=MVq/KO9mQWlEmONgPovYPC/moYBrzhnqRKihrSUsxEo=; b=hT2Fv8FE8LK02M/6QA3BdeUGZ+jx0aLo2Uik3V43G6XjXi5Cc3z12JcGlxpX+ur/kx sczZjugHdlq4vzoGrTHhpFR6nfALFrr2OI9XBnL60RiCt9y9IlPhe0QyYXZ8JYzYYi9D 7hLefG3+1FuXVyXXGmkh/vgBL84yi0/ctcKa7Ga65/PjejnXncSACw5ZQlep/whKBJni eT05yX5PEpqh4GdeSVTmrn1+CkwmDwItRt86kQUuHzMKmcNWM8qr6oX26KQywDSfVlLV +j6YKTI8iGAogmo5Icyc+w0YbCgmdjO7LjUgRHeuVH5R356E56kKKCv89TQ4YjjlHHR7 V9zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=MVq/KO9mQWlEmONgPovYPC/moYBrzhnqRKihrSUsxEo=; b=vyDI+3aGhpqdNDCA5y6H5Y5ky45N57vzXs5OxKBHhfoRRuYeBoFCOQMrsrBCHcvnQO t/iQqvNYrHtNDnhqM3UUebs2i4m2YgAtpCs8g6DYqpVUXbaZw4+QUCIOP1caGDySPdjf SeeNNKx3wujpsQAHlrXCVVGJvyXLQZITrP47nFtxePuwSgE096eJAVS6yWUeHArsw0Wj 5U7JIC+yBF6pHGp1Q3wQ1VPLqUglNpTFFSTnsUS1Q2yP3xLARLACVvUUDyvxodVtbQ5n OVUkgxdycXkt6i0j1XerwIId6aFhSAAXVCMua1U6TPg6aereS8vxQtCBPlurn5hf9UQ+ oEUQ== X-Gm-Message-State: AOAM5319NPples6plCgHzdld8PLhstzK9KvtCz8H40HmwVAGWRXOaJ8S IUKTi2JaoDXOviVlbExmeXIGPlxPDdI= X-Received: by 2002:a63:4cf:0:b0:363:c42:c135 with SMTP id 198-20020a6304cf000000b003630c42c135mr28266340pge.82.1646271950809; Wed, 02 Mar 2022 17:45:50 -0800 (PST) Received: from [10.100.0.6] ([194.5.48.183]) by smtp.gmail.com with ESMTPSA id z14-20020aa7888e000000b004e5c2c0b9dcsm457175pfe.30.2022.03.02.17.45.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Mar 2022 17:45:50 -0800 (PST) Subject: Re: [PATCH] platform: x86: huawei-wmi: check the return value of device_create_file() To: Hans de Goede , markgross@kernel.org Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220225130448.27063-1-baijiaju1990@gmail.com> <54dafc1d-bc72-8cb0-a539-4fdfc068cb5a@redhat.com> From: Jia-Ju Bai Message-ID: Date: Thu, 3 Mar 2022 09:45:48 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <54dafc1d-bc72-8cb0-a539-4fdfc068cb5a@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >> Signed-off-by: Jia-Ju Bai > 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 >