Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3974185pxb; Tue, 25 Jan 2022 00:22:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJzZuJoyoLCAHu7rYLwnnpxPxAefvhqxyankOCxKbU4q0AcuKgX0andAGZHWXYVC+gR0mwSx X-Received: by 2002:a05:6a00:890:b0:4bd:347d:8aaf with SMTP id q16-20020a056a00089000b004bd347d8aafmr17604963pfj.61.1643098973260; Tue, 25 Jan 2022 00:22:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643098973; cv=none; d=google.com; s=arc-20160816; b=I9d6vg6VoQMP22vA+1wQIxaUP7JoIzRel0TwQMErTxUhKEBo2tR2JE2onDUsNLDuOi sy8r5VkrrF6qgQ+m9leGyCON4fkNSocgznvAyMj0eMaK+FYPw7KJLWT7OKe0Izpn+QJa EnLJ5ZnIODaq3NFQkQffSuAhViAI+1HZbHnpiRLUeRj+kz5zXte/4wDLzXyqv1+TKJTL lyEBgNGB6jj8VnhA98YqDuzYnVY6p8ImQCaFKJb7l+dpW33yu0JfnJXyHLNWtm/reKUU IgIwwDiTwpxDLx1KUOt60Wt25ZcT+VxfszNuhx+gqb4GatV06grc9KwEa6ZUEobrCsAn mARg== 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=elpwi2iwK1eZDRiSD6GgmTuuLHeUdLsvlxTmwqUrX1PwW0uKaESI104pwfkye/DoZp JEvvratN6tJ7FD6YDvt0f3pSFfTR2X49Iy/Qpe8YAKC3TWVGqF5BwtbhlrpVF5N+9MH1 9UppD7+WyOELYMTUuFeNhEdK4svmCgg4SF2wbNKfBd5XSl6KjiegVumNB1W9r0giiWPH 4ylMVsflM7/znqFUmKNqhM9dg1+0yWZXLcBsww13ZR8WvznXCW16sB9PXIsl0VtH3vNi L4o38SOMth9mdTLTC3tqnGM8ZvJF1emF0QCdc/HDCE/zbMyCK06xdhnxAMKu71c6iRx+ hKUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TYqTILZ4; 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 q21si1378994pjd.81.2022.01.25.00.22.41; Tue, 25 Jan 2022 00:22:53 -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=TYqTILZ4; 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 S3420546AbiAYCYo (ORCPT + 99 others); Mon, 24 Jan 2022 21:24:44 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:40126 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347621AbiAXTKw (ORCPT ); Mon, 24 Jan 2022 14:10:52 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 0A5FD60918; Mon, 24 Jan 2022 19:10:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C045C340E5; Mon, 24 Jan 2022 19:10:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643051451; bh=sGOvretFgauqF2/LGbvj1iZr7JxVo+3umuYUrti16Ho=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TYqTILZ42sV7UVoXUiEbiM/hb10pYKDSFc99PSvnFCtOfqqtE+/7VLoTVZh2rQ5Sx 4/tx89p4eO3+6UaiHX91wLYPtnEmNen9+HjOsTkfsAXCgQgGrhXBGOHgChzQqgj2l3 PUrTs5ZWoRZ54tKaea1UilxMhWNjsYo7+wCxV6YU= 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.14 166/186] parisc: pdc_stable: Fix memory leak in pdcs_register_pathentries Date: Mon, 24 Jan 2022 19:44:01 +0100 Message-Id: <20220124183942.454961631@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183937.101330125@linuxfoundation.org> References: <20220124183937.101330125@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);