Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp627529pxb; Tue, 5 Apr 2022 16:28:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQGlwyvmsUYPtcu+su4Kc8x1l+X6TcmaXOqtyUXEXtWNZeR0O1ySGCSOJatZb2vZw0PODV X-Received: by 2002:a17:903:1105:b0:156:3e9d:bb7b with SMTP id n5-20020a170903110500b001563e9dbb7bmr5701868plh.136.1649201294381; Tue, 05 Apr 2022 16:28:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649201294; cv=none; d=google.com; s=arc-20160816; b=QwaWsvo6vLo5/Do7EwYguPZyQ7xBWx6/uZZHty4GBFDuElDPbx2FmS2Ocx+qk4Wnln k2FwMaqfDvDGR2n98XAS3bdUuN36W8IYfJSEShFZlwFgrymxq/eqw4I+iXHxkUYL4eFb iVAjgPYPwo2h3kOTPo3kJ4s8X7Ise7C+2WzXpBepnzoQ2FJEq8GXr4XR9bUVbblfSkAg 6yMw0YYMW6LiaqjEwkLvUo8lVxttKf7gejqqKVprzCs2b7QtzYe06/Zp+5WhX+V1kyMw gjUYQ4KGVOIquqsf07HmmiKNLq3cpGhEAeYK2LilHfNWP0xBMagfbYY1mkHu73EITHqk rVBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=j9kM4HUWOPGf6CIteaHxrtdeXwCEceAzF/VZf28NiHg=; b=zJ77aAYtlLZ+SAxbog2XjIqrEqZ+nBBfdqKN6O8ggrGEicR394ABC4Ykhemf+uK3Hj ym5mLSAfHsRZTsPcJJxf2QL6d4ZTW/x4PfK3uTlvszUUSDSp5GnJI6+KZI5jngGYMvyX jOY64lz/Ko10RWLf8wpDuHc7p7Sq5YKhhz3YO1rqKW92dOgeDPo+slE65t7aDV0juzxM 0Aav6pacTY3OpmyJ3qgKBfHGdJghV7YljUwhRKuNmLGwHl5bHAfzNkyYfy4G/c2bLAFb yFISMIE+BnNn7/VBeR8QE7Pz3aOIu6ReAg6MKO6OvFB4qFK2vc7Ed158SI3pnlQsONfd 7XeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=A8d+imwd; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id r28-20020a635d1c000000b0039905cd15f5si9427512pgb.574.2022.04.05.16.28.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 16:28:14 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=A8d+imwd; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8EB721179A6; Tue, 5 Apr 2022 16:11:52 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379673AbiDEMxS (ORCPT + 99 others); Tue, 5 Apr 2022 08:53:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243306AbiDEJIx (ORCPT ); Tue, 5 Apr 2022 05:08:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F06EF9F6F6; Tue, 5 Apr 2022 01:57:56 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 66F62615BB; Tue, 5 Apr 2022 08:57:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 784E2C385A5; Tue, 5 Apr 2022 08:57:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649149075; bh=qQkG5DprhOohE/vv7FqAicjZ5OSnoUow72LwglFkNNY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A8d+imwd02nQSix9ptaml37ORnduFW2HwAIGjyiAPidEgaMxZQssu+KU2EBykAJt7 XGcPTFxXmNEmV3wPDZ4zPIT2rMz/itrmYpk1CsZtuuBWbZUa2E/KBayTAzTzIivmFf PipxGL2vVIDkKi949wE11t3pxUo/oG2+RPrKux4A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, TOTE Robot , Jia-Ju Bai , Hans de Goede , Sasha Levin Subject: [PATCH 5.16 0584/1017] platform/x86: huawei-wmi: check the return value of device_create_file() Date: Tue, 5 Apr 2022 09:24:57 +0200 Message-Id: <20220405070411.615032299@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 From: Jia-Ju Bai [ Upstream commit c91a5b1c221a58d008485cf7d02ccce73108b119 ] 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 Link: https://lore.kernel.org/r/20220303022421.313-1-baijiaju1990@gmail.com Reviewed-by: Hans de Goede Signed-off-by: Hans de Goede Signed-off-by: Sasha Levin --- 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) -- 2.34.1