Message ID | 20230331180312.37997-1-W_Armin@gmx.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp749802vqo; Fri, 31 Mar 2023 11:15:05 -0700 (PDT) X-Google-Smtp-Source: AKy350a/kiCaMmytwqeHPhp4znz4PDSCDHn5c48qDzm+MYnkuq+NlwbsLfC9f86Ht0q1WCLJ75gA X-Received: by 2002:a17:906:e08b:b0:933:3aa7:57a6 with SMTP id gh11-20020a170906e08b00b009333aa757a6mr28574890ejb.12.1680286505048; Fri, 31 Mar 2023 11:15:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680286505; cv=none; d=google.com; s=arc-20160816; b=KV154DuDamcVu7oPFjGM8fyXfRT2kHZCgH29YwYN69pbxt8qYdhaeEHEQ1hm18OLBx Jbpu44+2j7eVentUiME6Fq2mciU3/RtXcgaZLH3sJgl5Ml90U5IRkSik8dscG6k0v2pM 9XIxYJLlSv9+91cHIb+iD4ffUEERYgc5kWryv9D2UQoxNXnP0tyg6CO8Dw0jjkhj0cj7 WLVUEz3FU67Ouzbjc8JXu7Uu9kwfX39k6A124fxC4gp7Xdz5vy6IAiGt3/7dpjx//+dN wHCZtIwZUNR2dLPg3A2Xy/r2gHebY6yw3eLQ7gMiuLvmO8i2I5l61L2Ic+pGL71IGDxI ZKGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=Npy4gd4fBRO0T06vE9VZZffx2iDp3KJo3QJd5NtEABw=; b=VMvtS7mhX2gz+RMk8EXIaC+JNoWAlxfC3Te6wJwGqJlFW3cCHR7xwOT3gjdzZud1VC RfBRhbp7CM6lzbaVysDKlzpCuVR6hzJbsPi3wh7vT560vUHjP8O2xJEAZ2b5M1QxnO0Q LR7gxuRaOOvdZjQK11M3tR6WbgnbG+eejzJHUJiuqLY0sEUHIg22KHZJj10c71oU2WIe OqsTVamqGVvs8Wsm21VesurmKmlANaFi3RNChCagSnp9FwZLSQa6ZLPG9hSJ+WXnK1DA H2mjMzpyswRPa+grUifeFqS3q6MrjPOArqkpnKcc/+3I0pdL+OaynSXxf8EYR8k5MyGm ttoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=Nyi60R1N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j10-20020a1709062a0a00b009333cd8a15dsi2280529eje.883.2023.03.31.11.14.41; Fri, 31 Mar 2023 11:15:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=Nyi60R1N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231982AbjCaSDg (ORCPT <rfc822;dexuan.linux@gmail.com> + 99 others); Fri, 31 Mar 2023 14:03:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231331AbjCaSDe (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 31 Mar 2023 14:03:34 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 484D41115F; Fri, 31 Mar 2023 11:03:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1680285795; i=w_armin@gmx.de; bh=2Lp2z+/qvRtTGAJyRpBMFhDcmIL5gFtMEMl6MY8KmRQ=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=Nyi60R1NTwYE6vrAUMzPEWG9a9EHDfE1Ecyg/CLaXNIpHWXLSXPgYgLRn5R5JnnVX 7q4MYpiv52ElUDiWjgMcpZ5EGhu0UcmrJsybcxzP+7rp4DGPCk+lyYxHHxrkHe0I/g Zl4+NqmQIr+le2oZYBfoZ/zhGz5p5WlR3r0uVtbEvR3lu5K6Lo2DpBVGxSZsHGPage R2lscL05RBJMCWxdutMcV4+WIQyxWdUzX0uPiepRy/uKU3gn2P4/mtiIzv8FzmMOZa a4Z7kcgssusIAdhahGwZsdL9iCdyOnToH69wM3kAJeHoCnCN2xzioEMoSkcQ0TgCbJ 3fCykEgaLDhbg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from esprimo-mx.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M7sHo-1pmAyn2Vdq-005106; Fri, 31 Mar 2023 20:03:15 +0200 From: Armin Wolf <W_Armin@gmx.de> To: markpearson@lenovo.com, mirsad.todorovac@alu.unizg.hr Cc: hdegoede@redhat.com, markgross@kernel.org, thomas@t-8ch.de, gregkh@linuxfoundation.org, rafael@kernel.org, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] platform/x86: think-lmi: Fix memory leak when showing current settings Date: Fri, 31 Mar 2023 20:03:12 +0200 Message-Id: <20230331180312.37997-1-W_Armin@gmx.de> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1: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wWGcYzmqQs/eixjq2XuTQNFTBX4HluSRNNv32+Ps6wBLbvuE1wxuOCnruaVHDZPfs9sRCoJfz V3uNuNlMX1DrLRvt1f87vtt9AbjSMFXS40MDvrRwTMS8PuwpqU8/QS1VK+o7O0yke4Z9xM0np FUAO5BIG8vTX9MgtcDHJjPcO8xU= X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761908102359129645?= X-GMAIL-MSGID: =?utf-8?q?1761908102359129645?= |
Series |
platform/x86: think-lmi: Fix memory leak when showing current settings
|
|
Commit Message
Armin Wolf
March 31, 2023, 6:03 p.m. UTC
When retriving a item string with tlmi_setting(), the result has to be
freed using kfree(). In current_value_show() however, malformed
item strings are not freed, causing a memory leak.
Fix this by eliminating the early return responsible for this.
Fixes: a40cd7ef22fb ("platform/x86: think-lmi: Add WMI interface support on Lenovo platforms")
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
drivers/platform/x86/think-lmi.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
--
2.30.2
diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c index cc66f7cbccf2..8cafb9d4016c 100644 --- a/drivers/platform/x86/think-lmi.c +++ b/drivers/platform/x86/think-lmi.c @@ -930,10 +930,12 @@ static ssize_t current_value_show(struct kobject *kobj, struct kobj_attribute *a /* validate and split from `item,value` -> `value` */ value = strpbrk(item, ","); if (!value || value == item || !strlen(value + 1)) - return -EINVAL; + ret = -EINVAL; + else + ret = sysfs_emit(buf, "%s\n", value + 1); - ret = sysfs_emit(buf, "%s\n", value + 1); kfree(item); + return ret; }