Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3548815pxb; Mon, 24 Jan 2022 11:59:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJyPCIB/3XxGyxAKon6fcENx+MFmQVmKhCMlGrSIZhmbhB3RZQv+EcTmuT1MIXwQuu/mLy7x X-Received: by 2002:a17:90a:d913:: with SMTP id c19mr3449419pjv.90.1643054368461; Mon, 24 Jan 2022 11:59:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643054368; cv=none; d=google.com; s=arc-20160816; b=p1Vwcbgf+qZkmAjDeh6mB0N+EvTjrBGq6w5t/SuIhNRpSH8ovK/KxB2mmdL4l1uwbK wVs3RddN1FvHRPVnjJUIYBRZJ1XE+ix5Og8+s4f/NA/v1QRbU74CJEoQwPZOExPYlJkk cc5tiU1PgLuIb5yl0aHaSyhOm7hV3x5Y0mIBS/YrtSQ1vWyGwQOo6BxvcJYcmbCRFXZq ZIh2yg1iPfF2J6qra2cimerCyfgW4Nz/0wUNV/LenZdn1CUav6S/wiGhfIKW3ozt2eAo VlfE5uzrPAKLjpWfsVSpPx0HLu4Mar8ujro/BCLdDWChDOHCeibPkrXTyVvvBS9Kw6QI AQyA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=smb6Q7VRjUSNrKcIh+4AkEQwpavq/Lkqq/LQl92meF4=; b=H8iO6Qdps40Y0LIomOhVItwGXURkipNYhl86zikgJBVCQFWPm/aHWmBIw+t8f1ZqO6 4PLPSvjHA38lj+kWY1jQAtnkdOUBkRIv7Ihjy7VfN5bJx2plfOMcINVyPysNlp5hRK/3 u2HsuqkOKkywS8DTUPCzjkqQnvN6SjHBXf47Njjn8Ky/j4pkDwfbJKjF0ShjH1VgMQkr /2JDwSo1YMg/2Zjq1YPNhlQQ5BElV9pnxPw7fA0v1FI/Ggbkni/jc1my4pOJ7D4AHUUb mwpv30OGoAeUKgn3wlk8ofo3D9Cl893KFzNXKJ3EFqyb8n9tv/SScvFg1zRh3lpbpFEd l+Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dOEMyXdM; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b5si15642164pfm.93.2022.01.24.11.59.14; Mon, 24 Jan 2022 11:59:28 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=dOEMyXdM; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343576AbiAXS5P (ORCPT + 99 others); Mon, 24 Jan 2022 13:57:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344263AbiAXSyF (ORCPT ); Mon, 24 Jan 2022 13:54:05 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DC11C0613E9; Mon, 24 Jan 2022 10:53:10 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2A04C614E3; Mon, 24 Jan 2022 18:53:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3D30C340E5; Mon, 24 Jan 2022 18:53:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643050389; bh=sGOvretFgauqF2/LGbvj1iZr7JxVo+3umuYUrti16Ho=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dOEMyXdMc+GAwbXcsr7qK+YVSIRsvynzpBmj/4Qq50u08KpAYmNXD79FIiVRGZAW7 56NHAyXF2ps5H6wYRVaB7UJs2u/I0wQW8Rm19J+/W7/vJFV24demf0IiYvwJ8w7kWm o6e4HykwupjITpgzla2MroBLwisd5B1UBgh+2YQc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Helge Deller Subject: [PATCH 4.4 103/114] parisc: pdc_stable: Fix memory leak in pdcs_register_pathentries Date: Mon, 24 Jan 2022 19:43:18 +0100 Message-Id: <20220124183930.290507116@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183927.095545464@linuxfoundation.org> References: <20220124183927.095545464@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miaoqian Lin commit d24846a4246b6e61ecbd036880a4adf61681d241 upstream. kobject_init_and_add() takes reference even when it fails. According to the doc of kobject_init_and_add(): If this function returns an error, kobject_put() must be called to properly clean up the memory associated with the object. Fix memory leak by calling kobject_put(). Fixes: 73f368cf679b ("Kobject: change drivers/parisc/pdc_stable.c to use kobject_init_and_add") Signed-off-by: Miaoqian Lin Signed-off-by: Helge Deller Signed-off-by: Greg Kroah-Hartman --- drivers/parisc/pdc_stable.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/parisc/pdc_stable.c +++ b/drivers/parisc/pdc_stable.c @@ -992,8 +992,10 @@ pdcs_register_pathentries(void) entry->kobj.kset = paths_kset; err = kobject_init_and_add(&entry->kobj, &ktype_pdcspath, NULL, "%s", entry->name); - if (err) + if (err) { + kobject_put(&entry->kobj); return err; + } /* kobject is now registered */ write_lock(&entry->rw_lock);