From patchwork Tue Jun 16 15:34:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 224417 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A520C433DF for ; Tue, 16 Jun 2020 16:01:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 68C92207C4 for ; Tue, 16 Jun 2020 16:01:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592323305; bh=z8VABR2iloijjO5oU3eoMWMuhLAhwBXfYG9CbcWJDuk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=1aME0ts/aBfwVFM4Negd5ycALBf3VqkyV/oXnPBRjaXgYZe4sCiDnzSVoA30yagYE aAXs7n0HACUXSpjJXLrj0Aw6nZ5qfUpiUHfvtpUqNKcR0cbbr9fYt1cnwbR+Q4Kjs4 BWjZuvrN+axUT/cFbM9V8OImU+Gj21zSADZv2Fec= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732721AbgFPQBj (ORCPT ); Tue, 16 Jun 2020 12:01:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:48942 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732728AbgFPPv6 (ORCPT ); Tue, 16 Jun 2020 11:51:58 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B92F5207C4; Tue, 16 Jun 2020 15:51:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592322717; bh=z8VABR2iloijjO5oU3eoMWMuhLAhwBXfYG9CbcWJDuk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JFXIqocHV01nGb9kKqpQ4E7Z/oNrUSGZmvAqWDyh9Ks7Kv8M6dh5x0pT6YwhuX/kd 6JAstHDPdcH7o2uaVl2sA76JmWsSNE/JCbW24CVluaiJMncX1c4KpnYYT6qvAQP6ii qRMdaLaaSifpDvloYJYK9iPJ28ub8OIsi3lsiD3Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qiushi Wu , "Rafael J. Wysocki" Subject: [PATCH 5.6 077/161] ACPI: sysfs: Fix reference count leak in acpi_sysfs_add_hotplug_profile() Date: Tue, 16 Jun 2020 17:34:27 +0200 Message-Id: <20200616153110.047742478@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200616153106.402291280@linuxfoundation.org> References: <20200616153106.402291280@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Qiushi Wu commit 6e6c25283dff866308c87b49434c7dbad4774cc0 upstream. kobject_init_and_add() takes reference even when it fails. Thus, when kobject_init_and_add() returns an error, kobject_put() must be called to properly clean up the kobject. Fixes: 3f8055c35836 ("ACPI / hotplug: Introduce user space interface for hotplug profiles") Signed-off-by: Qiushi Wu Cc: 3.10+ # 3.10+ Signed-off-by: Rafael J. Wysocki Signed-off-by: Greg Kroah-Hartman --- drivers/acpi/sysfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/acpi/sysfs.c +++ b/drivers/acpi/sysfs.c @@ -993,8 +993,10 @@ void acpi_sysfs_add_hotplug_profile(stru error = kobject_init_and_add(&hotplug->kobj, &acpi_hotplug_profile_ktype, hotplug_kobj, "%s", name); - if (error) + if (error) { + kobject_put(&hotplug->kobj); goto err_out; + } kobject_uevent(&hotplug->kobj, KOBJ_ADD); return;