From patchwork Sat Aug 5 05:36:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 131441 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp292532vqr; Fri, 4 Aug 2023 23:12:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFgj7K/x6359tAtLKDX/mPGgRSOtTcYOjWgZik1C6ot7O6+Jzyn4HTPzYlW9ImLoP9jJhVy X-Received: by 2002:a17:902:f693:b0:1bb:7d2f:7c19 with SMTP id l19-20020a170902f69300b001bb7d2f7c19mr4579255plg.64.1691215951922; Fri, 04 Aug 2023 23:12:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691215951; cv=none; d=google.com; s=arc-20160816; b=QRh487S2UqV9EbGwHg2Q6U3Q1ndZZcpclBYXKu0dVg4Hl3SBWqKU02wpZrD84dBxSw Qk2/YxpglD9C6uahZiq2ut5TvFqH7Wu0Tc2I4/J2JdIEM3KnVebWoo2HAg0sUJRpw2KE yDTjsCavlNnJL5l91er5W1CywAjQA+fMxNMiFa4dPNWwTubsOuo9lDOqUbPdQTjwTvK7 ClOWq5wLP9rhbs1vzOGwCmoNc7xvjGVFQiApb2202i1vPnbiSNeXuslpRiociZEXsy3s dQguki+V5IiDqPS62PhI37+/2RnHq6maA6Wo1VMaZF/gYdD2XsRPzxNAt6CunVA9Wgzf SU7w== 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=kEGhPzXMYePV/Jlt5jk4DFtHpZ+3wMxEH5Cl+glWLIc=; fh=IimzwwkUlwI5Pyptv4XejKICTw+a2ELPlXTRcSRIuAU=; b=GH9fmFw4NdHQO8lq5+Z/Lprokq01HNXrXPobkOEem0tUcU0OaZTTxfadYjvOKhvLft 1PJwYh/o4cvopCU0MxBoxc1rWDAP/6O6C9E8dHSdNWnAh1SO2/7uwMO/q5udcydEhsX8 ri5Klm765RqjJKpAK7I9jUnwDtAAzdMJMeQl43GQm+Hf7U8bB/EUePwqSQ+zjjMpTjE4 yhBcvjnnG2W68XhnexGmdEL9xyoFLFn/XDhMncQzKAaNArj/a5pfqpKucKcSpZIykGic /PBUWvlE8r+irFWHS5AA0NSJSeQoTxGgTd14Ymm5+hYO7CZIaolCsgpBboUehU7T3fRm mvjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=WztmmToY; 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 om1-20020a17090b3a8100b002610f13639asi6257407pjb.91.2023.08.04.23.12.16; Fri, 04 Aug 2023 23:12:31 -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=WztmmToY; 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 S229534AbjHEFg1 (ORCPT + 99 others); Sat, 5 Aug 2023 01:36:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbjHEFgZ (ORCPT ); Sat, 5 Aug 2023 01:36:25 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DC8146B3; Fri, 4 Aug 2023 22:36:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1691213772; x=1691818572; i=w_armin@gmx.de; bh=Xc5Uz3yHM1cYmTbfdHFbQvSyh54bIq4BmIZkafOGP8Q=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=WztmmToYD9V4MELG/sZBCibor6a4SSfMWRdoyJwHc7C0tXWvmk3fm8nxyAbcqUfSXxfkXJe k28cl35Y2q8MG3wnrNhURND5OZxLtlHM3JuAGpiU9IXEm3ef7qZciXWR681lqMjlYWmX757Xo Z4Zu9YgtYe66nxjySsjLkYbpkQNmwY4JYKiqL1f0LdnPAFq+F7ynjM8xfZWC1q8jb5IO7zzvk mnas6TjctvI9KBwczHsxQXDkJEjvoDssLcR5gWbZNQuD/1M8YCW7cls5jtLwsui1z5FWuxZ+n qN7mM0A/o8Q7DzUOGBVa12xXz3OSNt11IPQYRGfh1Ve2+MzQu6Sg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from mx-amd-b650.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N6bfw-1plbjW1n14-01816B; Sat, 05 Aug 2023 07:36:12 +0200 From: Armin Wolf To: prasanth.ksr@dell.com, hdegoede@redhat.com, markgross@kernel.org Cc: Dell.Client.Kernel@dell.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] platform/x86: dell-sysman: Fix reference leak Date: Sat, 5 Aug 2023 07:36:10 +0200 Message-Id: <20230805053610.7106-1-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Provags-ID: V03:K1:1Ex/nogT+uSYoxHzoSeE2GZ+pKYhOchFCLlj5z6jU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XWQRl2h/H3+cSEjKHrVFLCe/ILxAyf94EAkSUNWBl3C/n1LtvQY mkY5EVMNLEznoNJmsWGkfjvKSWyaA9WdMm8dwUGif/n7JLmxCok76xE0j4Nu/yyHmifFLaxd6 xtC+tTaLCJiJkPzV4iZ57AOctyM= X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773368458022442557 X-GMAIL-MSGID: 1773368458022442557 If a duplicate attribute is found using kset_find_obj(), a reference to that attribute is returned. This means that we need to dispose it accordingly. Use kobject_put() to dispose the duplicate attribute in such a case. Compile-tested only. Fixes: e8a60aa7404b ("platform/x86: Introduce support for Systems Management Driver over WMI for Dell Systems") Signed-off-by: Armin Wolf --- drivers/platform/x86/dell/dell-wmi-sysman/sysman.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- 2.39.2 diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c index b68dd11cb892..b929b4f82420 100644 --- a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c +++ b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c @@ -393,6 +393,7 @@ static int init_bios_attributes(int attr_type, const char *guid) struct kobject *attr_name_kobj; //individual attribute names union acpi_object *obj = NULL; union acpi_object *elements; + struct kobject *duplicate; struct kset *tmp_set; int min_elements; @@ -451,9 +452,11 @@ static int init_bios_attributes(int attr_type, const char *guid) else tmp_set = wmi_priv.main_dir_kset; - if (kset_find_obj(tmp_set, elements[ATTR_NAME].string.pointer)) { - pr_debug("duplicate attribute name found - %s\n", - elements[ATTR_NAME].string.pointer); + duplicate = kset_find_obj(tmp_set, elements[ATTR_NAME].string.pointer); + if (duplicate) { + pr_debug("Duplicate attribute name found - %s\n", + elements[ATTR_NAME].string.pointer); + kobject_put(duplicate); goto nextobj; }