[v2,2/2] platform/x86: think-lmi: Clean up display of current_value on Thinkstation
Message ID | 20230403013120.2105-2-mpearson-lenovo@squebb.ca |
---|---|
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 b10csp2012907vqo; Sun, 2 Apr 2023 19:04:36 -0700 (PDT) X-Google-Smtp-Source: AKy350bjqe+pZu8gJmymf6XzUt6T76T9Std2EaeeWWEVpqzQGseHHs+E94cJ+ZWGdkDjP0c/OUq+ X-Received: by 2002:a17:906:3451:b0:948:a58a:5230 with SMTP id d17-20020a170906345100b00948a58a5230mr577670ejb.33.1680487476261; Sun, 02 Apr 2023 19:04:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680487476; cv=none; d=google.com; s=arc-20160816; b=AdnpxwB7+rn3supPdbCp3Cl2cenasQB4wrHx0aKR27h2hQtn5DMLiA+/zIuAxahm+y maolzqRGNpdukBzMwoqGOovLXaqPP8sIWubEZKelnRJoK1e2CZsi8oHCNo5+gb+68c8+ ZGnsKUUnyxlQXUROj8kVDkmeupTBe+90ecxdr5I0RwD8cAjttTw6B0yJhHRsYUuq5y54 uViouYoqVap8FQtwtdVM0borDGhEZ0RARLoh5u38+3lFeQwQbLhnj7SgN0noL94fgVyX iqYBN2ehBZdLVpyZNNRRu+Z7j+LrKPplUElZP3ycp/Sz6fUMndnWFnpqXvXbtX+oTUwV lz7g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=GX5wswwc9ioI6tRN/FjlVtZp/Nq/YYWiACOgX926AhU=; b=mAua2QyVRiAQK6Yl8KdWF8Mxjs1EahoqLLlJvmzz0458Xkcj1GGi5Tb4veiAq1T+Es zmfqMU6gnPs5Qx5Euaq7YqPg/+ypEQbsGJdk+PymifPD/r9/b1JrPbM3wuD4PNL6MFNf /l2OPS4cBxLFF8wqgbSk0rl/nHILEApowd6MKH1gB1ftoTdoPNMgtUdOYOOIhHofZWJY TgdixS6iErrlKidWMR8cKnnRXEmWkMW6/bwdb/Ovu1RaHpn0BibWzGDUO8u7RQYIPfvd bVpcmA7QO4gjB5Wg3VpDuHzKU7So7fLt7sFA/P32CFtMLIYRpoieazsXEMtOaz6zc2AC aMcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@squebb.ca header.s=fm3 header.b="kjvI/wcS"; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=NeadoCMT; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z10-20020a1709063aca00b0092292a828afsi6013704ejd.505.2023.04.02.19.04.12; Sun, 02 Apr 2023 19:04:36 -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=@squebb.ca header.s=fm3 header.b="kjvI/wcS"; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=NeadoCMT; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231419AbjDCBbj (ORCPT <rfc822;dexuan.linux@gmail.com> + 99 others); Sun, 2 Apr 2023 21:31:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231410AbjDCBbg (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 2 Apr 2023 21:31:36 -0400 Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1579410F5; Sun, 2 Apr 2023 18:31:35 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 04D7B320097D; Sun, 2 Apr 2023 21:31:33 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 02 Apr 2023 21:31:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=squebb.ca; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1680485493; x= 1680571893; bh=GX5wswwc9ioI6tRN/FjlVtZp/Nq/YYWiACOgX926AhU=; b=k jvI/wcSLRN6fbepGKRvkXa2+d9zF6mRgCctN8I5PvW0abPl/v99Kc7W9zmhQiQn8 htgS1BnJecx2x4I2Aef98y45xPSwT42i68dTZ8BGVqiI60tZOBQpwyqN/HhB8OhU I7B9xgCpk1p1s1yZLOBx4uaNWub6U+R/+Ns75nT5oABdbYDu+FxJZ60Xc/bYB0I/ pvOLQr9rhfDC5MCdEjopQ5TfKoZ0miaVIqR8fWRpotpte7NXCHRJk/dKw5zmsxBy 9Uj7cv0xcl5i1ZoEB2kOlO7kcNL5zHQAA1qcGed8DhtiRLnsyOSgqsjxfZ2jCnDU 17Hz7kDrdwQBr5eWQAdXA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1680485493; x= 1680571893; bh=GX5wswwc9ioI6tRN/FjlVtZp/Nq/YYWiACOgX926AhU=; b=N eadoCMTTS1OHj+Vfzz2utLNUDfg59wMkzdp0LD1oXdzCXuSzaMd5SZvqY8StZ8Ut lCCqvzzz9YJSy8SbGlsvehd8igxbTT+SVSHDnZsf+VylLPP59xXXvYgRQ2tZEolf 5EjB4cEj/XUPtp0drfWD1/AHCyzJVaZ4B9dmNEi/f3whnSjGh+jU6x0Cmgq8lYRN 3n+owPVVWKNQU3/Tpuu1ubTkWEbs6CygJMfnYE76nAI8HlQd322IsQR48g72BSRV tuN05HHpsVypBr3wVyT16czamhjR25lTYiP5EWrVej9L4EEAScjErNhQ/rLnl668 pLGCJ1mI2rCa7ZGL96e5A== X-ME-Sender: <xms:dSwqZKjXKNCjo2bcmlLG1Bg1TxzJmigzFk458uqxy1slp97QlSNi6Q> <xme:dSwqZLDe-hmNHRubbWfMjD66awYmSE2e5nOCetHKX0OBuhozweWqSCube2LxFiEnD gKmO26t4urx_OmbbtI> X-ME-Received: <xmr:dSwqZCFJg1Xs7yfctVmCj9wMKEFPndIbqBvZ2Hzios-xJU3XyfvMStHs5Odi4rSQqI44VtX0Hn9uDeYwiAfCyZbuLuFhVl9gC6lt2xbRJJrFMuMdkzD7Yvj1380DVZcHYe1CKyxzKQ> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdeiiedggeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucgoteeftdduqddtudculdduhedmnecujfgurhephf fvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrrhhkucfrvggrrhhs ohhnuceomhhpvggrrhhsohhnqdhlvghnohhvohesshhquhgvsggsrdgtrgeqnecuggftrf grthhtvghrnhepkeefudeutedutdegheejhfdvieehjefhleefgfevtdeivdfhleehiedu feegffeknecuffhomhgrihhnpehgihhthhhusgdrtghomhenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmphgvrghrshhonhdqlhgvnhhovhho sehsqhhuvggssgdrtggr X-ME-Proxy: <xmx:dSwqZDQ16anNhggnm38AxsUvYYojFlU05xkZB-9WP9mmzed6TG8clw> <xmx:dSwqZHwjTD5JjpFTZD7A8PhixewnT8ATesN0AILdCKtL5PxwnC38Xw> <xmx:dSwqZB4gg60M5zx4oP3eUbgPWNFAK1qrpYlCxDPP4eCzoThRl5Mb5Q> <xmx:dSwqZOx0mWjit4CZZznOF56tp_3Mqnfdul41SNQyDSweon6ILbriXg> Feedback-ID: ibe194615:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 2 Apr 2023 21:31:32 -0400 (EDT) From: Mark Pearson <mpearson-lenovo@squebb.ca> To: mpearson-lenovo@squebb.ca Cc: hdegoede@redhat.com, markgross@kernel.org, W_Armin@gmx.de, mirsad.todorovac@alu.unizg.hr, linux@weissschuh.net, Mario.Limonciello@amd.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] platform/x86: think-lmi: Clean up display of current_value on Thinkstation Date: Sun, 2 Apr 2023 21:31:20 -0400 Message-Id: <20230403013120.2105-2-mpearson-lenovo@squebb.ca> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230403013120.2105-1-mpearson-lenovo@squebb.ca> References: <mpearson-lenovo@squebb.ca> <20230403013120.2105-1-mpearson-lenovo@squebb.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,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?1762001165022763276?= X-GMAIL-MSGID: =?utf-8?q?1762118836109730763?= |
Series |
[v2,1/2] platform/x86: think-lmi: Fix memory leaks when parsing ThinkStation WMI strings
|
|
Commit Message
Mark Pearson
April 3, 2023, 1:31 a.m. UTC
On ThinkStations on retrieving the attribute value the BIOS appends the
possible values to the string.
Clean up the display in the current_value_show function so the options
part is not displayed.
Fixes: a40cd7ef22fb ("platform/x86: think-lmi: Add WMI interface support on Lenovo platforms")
Reported by Mario Limoncello <Mario.Limonciello@amd.com>
Link: https://github.com/fwupd/fwupd/issues/5077#issuecomment-1488730526
Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca>
---
Changes in v2: For some reason v2 doesn't apply cleanly so rebased and
started again. Hopefully this one works
drivers/platform/x86/think-lmi.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
Comments
On 4/2/23 20:31, Mark Pearson wrote: > On ThinkStations on retrieving the attribute value the BIOS appends the > possible values to the string. > Clean up the display in the current_value_show function so the options > part is not displayed. > > Fixes: a40cd7ef22fb ("platform/x86: think-lmi: Add WMI interface support on Lenovo platforms") > Reported by Mario Limoncello <Mario.Limonciello@amd.com> > Link: https://github.com/fwupd/fwupd/issues/5077#issuecomment-1488730526 > Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca> > --- > Changes in v2: For some reason v2 doesn't apply cleanly so rebased and > started again. Hopefully this one works Tested-by: Mario Limonciello <mario.limonciello@amd.com> tested on 6.3rc5 + prerequisite Armin's patch. > > drivers/platform/x86/think-lmi.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c > index 87f832142d8d..78dc82bda4dd 100644 > --- a/drivers/platform/x86/think-lmi.c > +++ b/drivers/platform/x86/think-lmi.c > @@ -920,7 +920,7 @@ static ssize_t display_name_show(struct kobject *kobj, struct kobj_attribute *at > static ssize_t current_value_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) > { > struct tlmi_attr_setting *setting = to_tlmi_attr_setting(kobj); > - char *item, *value; > + char *item, *value, *p; > int ret; > > ret = tlmi_setting(setting->index, &item, LENOVO_BIOS_SETTING_GUID); > @@ -931,9 +931,12 @@ static ssize_t current_value_show(struct kobject *kobj, struct kobj_attribute *a > value = strpbrk(item, ","); > if (!value || value == item || !strlen(value + 1)) > ret = -EINVAL; > - else > + else { > + /* On Workstations remove the Options part after the value */ > + p = strchrnul(value, ';'); > + *p = '\0'; > ret = sysfs_emit(buf, "%s\n", value + 1); > - > + } > kfree(item); > > return ret;
On 3.4.2023. 3:31, Mark Pearson wrote: > On ThinkStations on retrieving the attribute value the BIOS appends the > possible values to the string. > Clean up the display in the current_value_show function so the options > part is not displayed. > > Fixes: a40cd7ef22fb ("platform/x86: think-lmi: Add WMI interface support on Lenovo platforms") > Reported by Mario Limoncello <Mario.Limonciello@amd.com> > Link: https://github.com/fwupd/fwupd/issues/5077#issuecomment-1488730526 > Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca> > --- > Changes in v2: For some reason v2 doesn't apply cleanly so rebased and > started again. Hopefully this one works > > drivers/platform/x86/think-lmi.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c > index 87f832142d8d..78dc82bda4dd 100644 > --- a/drivers/platform/x86/think-lmi.c > +++ b/drivers/platform/x86/think-lmi.c > @@ -920,7 +920,7 @@ static ssize_t display_name_show(struct kobject *kobj, struct kobj_attribute *at > static ssize_t current_value_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) > { > struct tlmi_attr_setting *setting = to_tlmi_attr_setting(kobj); > - char *item, *value; > + char *item, *value, *p; > int ret; > > ret = tlmi_setting(setting->index, &item, LENOVO_BIOS_SETTING_GUID); > @@ -931,9 +931,12 @@ static ssize_t current_value_show(struct kobject *kobj, struct kobj_attribute *a > value = strpbrk(item, ","); > if (!value || value == item || !strlen(value + 1)) > ret = -EINVAL; > - else > + else { > + /* On Workstations remove the Options part after the value */ > + p = strchrnul(value, ';'); > + *p = '\0'; > ret = sysfs_emit(buf, "%s\n", value + 1); > - > + } > kfree(item); > > return ret; I can confirm the build against the Torvalds 6.3-rc5 tree and Armin's patch applied w these. [root@pc-mtodorov kernel]# uname -rms Linux 6.3.0-rc5-mt-20230401-00005-g10de4cefccf7 x86_64 [root@pc-mtodorov kernel]# cat /sys/kernel/debug/kmemleak [root@pc-mtodorov kernel]# echo scan > !$ echo scan > /sys/kernel/debug/kmemleak [root@pc-mtodorov kernel]# cat /sys/kernel/debug/kmemleak [root@pc-mtodorov kernel]# echo scan > /sys/kernel/debug/kmemleak [root@pc-mtodorov kernel]# cat /sys/kernel/debug/kmemleak [root@pc-mtodorov kernel]# echo scan > /sys/kernel/debug/kmemleak [root@pc-mtodorov kernel]# cat /sys/kernel/debug/kmemleak [root@pc-mtodorov kernel]# The leak is apparently gone in the original setup that reproduced the leak. At your convenience, you can please add Tested-by: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr> Have a nice day. Best regards, Mirsad
diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c index 87f832142d8d..78dc82bda4dd 100644 --- a/drivers/platform/x86/think-lmi.c +++ b/drivers/platform/x86/think-lmi.c @@ -920,7 +920,7 @@ static ssize_t display_name_show(struct kobject *kobj, struct kobj_attribute *at static ssize_t current_value_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { struct tlmi_attr_setting *setting = to_tlmi_attr_setting(kobj); - char *item, *value; + char *item, *value, *p; int ret; ret = tlmi_setting(setting->index, &item, LENOVO_BIOS_SETTING_GUID); @@ -931,9 +931,12 @@ static ssize_t current_value_show(struct kobject *kobj, struct kobj_attribute *a value = strpbrk(item, ","); if (!value || value == item || !strlen(value + 1)) ret = -EINVAL; - else + else { + /* On Workstations remove the Options part after the value */ + p = strchrnul(value, ';'); + *p = '\0'; ret = sysfs_emit(buf, "%s\n", value + 1); - + } kfree(item); return ret;