Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3664410pxb; Mon, 24 Jan 2022 14:48:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJzw2oquREXyZW1mGn92z8SPAGASTlIOyoXbFCRbdwuoM9WfFloR27RHx1JeY6qZNRAMKvFC X-Received: by 2002:a17:90a:db97:: with SMTP id h23mr492432pjv.163.1643064534862; Mon, 24 Jan 2022 14:48:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643064534; cv=none; d=google.com; s=arc-20160816; b=dtTq/tYZzmTdydhcaR/H1AlyefWZrCXx3c4NWUzhmbYpqPas1zHXGlQKSi76DGFkls iJb+jLxvIQbiQXvgYxwGjASRQp1Mar+kLt/FxUOXgRPYg47cKswfe/ces3ULrbxSvRkc UKRb9tYZP9t3SvwPWTQhZkAvuPI/KzsZ/VP2GT7iFjYwoTjOMSVQpud5D/ZH1gYSPOEI 7KY2urTfwIAtIGVuSadbkAglvpKAHhVDbGKvmGVdkuPAftu5Yy1PLInZAPowYe8RHmpg la3Q6T8aNI3dPVoeEQ8fbEPqYbDj2Pm/hK91WvhSsh0lvkdjjk/qd+meD7DiPKDxA4NG zDOw== 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=neCYLovQTF2VL6DDNVAWB/GynJLSb+MrNMr4qwlPBzU=; b=fUx8pLUc1fZS9kmpjoi2nRCxLDDMV8Kh8lvj5Mv1LnMXLe0XWnew4wO2UURWYWTNFX lhtd9qoIzr7nH/1UwdIFP/NLvjz30ta2XR15k8q+1+cMyzHku8ZKOO+zXH1oIhFWfP7r wG4yBZKlyrTXhdgDChyv87SSKuNUoGM+lQQeWhyOFMJtc+M9hjUoa6cyDU3NL93TMffv 5x1DnqEEP4CS8zmMwGSCsWqmriKAa2pEmh3mcWOwCSK3xyeDn6XHR37vMZd6BaXZJbfy CEcV/zqMTCz19ar39umHx1IWpDXRLnpUuoPqGbV2kgkNQCHOIm93tca0BShVQr4fXfOb mbIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bh6g7Swy; 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 l191si6598909pgd.131.2022.01.24.14.48.43; Mon, 24 Jan 2022 14:48:54 -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=bh6g7Swy; 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 S1838071AbiAXWpw (ORCPT + 99 others); Mon, 24 Jan 2022 17:45:52 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:51662 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1457005AbiAXVkn (ORCPT ); Mon, 24 Jan 2022 16:40:43 -0500 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 ams.source.kernel.org (Postfix) with ESMTPS id 4BF7DB80CCF; Mon, 24 Jan 2022 21:40:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73803C340E4; Mon, 24 Jan 2022 21:40:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643060440; bh=x1ittnNsJWwt1zDpNreQd8A+qpmVXaypmHKKZugegkE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bh6g7Swy7+QKD5BvqGnelkT4dWbxl1tArGk37YWxFkrrzccW0ebvR2BSoraRx2xiy jzD6Nt/JVdVOIHz43A71pudtjQZpL+Xey0B+Ej4MX/l2K090bIG5khl3U2LKBI24Os xdt69CRnriyXuRkUjQ/3+hFsvKOpdNH/L7rmb7I4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Helge Deller Subject: [PATCH 5.16 0949/1039] parisc: pdc_stable: Fix memory leak in pdcs_register_pathentries Date: Mon, 24 Jan 2022 19:45:38 +0100 Message-Id: <20220124184157.188315636@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@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 @@ -979,8 +979,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);