Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp994488ybt; Fri, 19 Jun 2020 20:57:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxf0DNU3vy0ZHC5PptDbcU/YLpWxJHchOV4QTJSxRICcFQ9sZjZHs4yTgnPwBy+5+1aSZ/j X-Received: by 2002:a17:906:899:: with SMTP id n25mr6103839eje.298.1592625425641; Fri, 19 Jun 2020 20:57:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592625425; cv=none; d=google.com; s=arc-20160816; b=zguy5Uq2XHhyz5dD5IqZlgjGQgaodLXthOIK7r8KOvygN7ZlJFVEciLgQvafWO5KjT YP8mweXVcCO1/DEHvCVzMOvUnsR6FQsvkw7GBARir9QyyC+rJmRu6XctfSqYzVPjP0cV SBKjkpPVVBJ6SVBUz80Y9/0/25S8HRRtB++aQYysL+767xqPgUbIWfsaiArE3MCNUr4t LEbUuAnKiR5be6tFdTVF3JPH8Ov+kFudbMtJrkd7TKaHltjUTUeI1mqtok4a+0Xirqxy Xjl+sKsa1ZEmqSF4VXx8g+cDOt6PuN1zEjNcVKC4Ro7pNnGci4g04DPlZopsTL2jIiG1 CcVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=r2JESAYM1NGWbCwJTRlcsGFxpDzjL2s4RkcdEUTQ4Mc=; b=lDWga94qGAjlCfPkU69PVVaAnSplXhhX9dUvgjur1Ryzt4fZcFTOIdM6S1j/yLnIaK rtggE4rW8lt7tjR/NkrSAwcmKoU+FWTyKeH894zN2NgxdtUTsaAuQtEy/7EtN29Dh343 sgN6aMT66JvitijON4LikYS1n+CfIGwku4KXbnOO1vvehKUQGC34kOC/TS+DheF1ZWMr V2ED1sA+VC0pxM1sDQ9lF4vPoMsEkoiwb4qmbex+qnVCGgAFvIhB4vwpd3RSAjxiuh+v sJ9vRTpwK8kMHh2+zXyD5eJVmgT7/SXxsiU88MDCpt104P0STcD6htkgzySG+JqAz65i HJgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xCvB6J8G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id od24si5150940ejb.103.2020.06.19.20.56.44; Fri, 19 Jun 2020 20:57:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xCvB6J8G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394988AbgFSQ3e (ORCPT + 99 others); Fri, 19 Jun 2020 12:29:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:49318 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389869AbgFSOyg (ORCPT ); Fri, 19 Jun 2020 10:54:36 -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 5CFE52184D; Fri, 19 Jun 2020 14:54:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592578476; bh=bxcjDPu7LuqRjHCweOM9LMQWJan+q+nNWni1LRISz/Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xCvB6J8GITRryZ7ikQChvAISajv5ozvRZ9N0m8z0wTednS2bIHIAhId8QJNrDsfTi OR1i3cjav9A/YRvfcVVqfyp1YcZ+cbsNGvI4BkDn+nvdHz/vh3w4ZZMDc+yzoly5J4 2Kc7w4zZoEwzI7DQev5gGIJ9iVQ3M2/RMw12m1v4= 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 4.19 037/267] ACPI: sysfs: Fix reference count leak in acpi_sysfs_add_hotplug_profile() Date: Fri, 19 Jun 2020 16:30:22 +0200 Message-Id: <20200619141650.618131064@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141648.840376470@linuxfoundation.org> References: <20200619141648.840376470@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 @@ -990,8 +990,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;