Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3577051pxb; Mon, 24 Jan 2022 12:38:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJzsh8XEHUoiYChWns3qC0fc4w3iWqy2QvuA3USz4sg4J5oij0Mxuzt6x3uaHzEnkdSJ6bAs X-Received: by 2002:a63:be45:: with SMTP id g5mr13091850pgo.309.1643056709783; Mon, 24 Jan 2022 12:38:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643056709; cv=none; d=google.com; s=arc-20160816; b=Dd80KTSKuKmnVfNerGriZ4af8B1S6TdI5WLnJUXhhNLkBuZAspyNDCASAD28koQ2kR hX3o8ACXCNr5SD8gAr81iFRRR8wqj6oOR8RKCAsNFnrJG8Ro0AXwT5ranTQUyqpH4UKP EpDlsS1sA8Luyjw6U72x5NQcRysFG/AjcDqLBkk+N4oN64XX9LyWLXaosstYmmmCleBY O8gNFafjZ2rG6TuCe8qDOwc7xgfFNf8FTW4KM+ht8jAXVn/uBjCAOa+jO8esxxIW4TNS Im6ksRj1862NLMrtTL2QpC+8FTNeodM1XsnUYzsadYkWWhdAogdhFXn8eiwLV9hYVoI8 T1ig== 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=avJdFNnVFjCIALOP+/lyLO7blbi+C8s5xpaidpAJ24ZBnzxKxeWnFqAGWawl82TTY/ 9SCUIBNypoPMBRrYwwbtre3Gta9gyTM/Mk7bnulLWna3jLGQwvV+ikKaao87BJupIDzs bGzYhiemk6T4lNjSq8Z2cqxn2Bvyv01cFURLB11Vga0h/7A1aL+9SGywc/HiwvGcl7xY E6iZibqNjDqjwf4zc7L+NkK8yDXq9jUlsbW8bqficTAfeXEpV8H2Eq+3Fpw+8GiVsV9Y lgRUF+/on6vvMl5UOGZvC/MN/nRZVteqrcPQBd8AWRW1HtgR3/1KVBQvoR+PoUxmAL+r JtLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rqBkDYjr; 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 k63si315202pja.45.2022.01.24.12.38.10; Mon, 24 Jan 2022 12:38:29 -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=rqBkDYjr; 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 S1357190AbiAXTtf (ORCPT + 99 others); Mon, 24 Jan 2022 14:49:35 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:59836 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353888AbiAXTjG (ORCPT ); Mon, 24 Jan 2022 14:39:06 -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 D85BBB81229; Mon, 24 Jan 2022 19:39:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF2C3C340E5; Mon, 24 Jan 2022 19:39:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643053143; bh=x1ittnNsJWwt1zDpNreQd8A+qpmVXaypmHKKZugegkE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rqBkDYjrtWrcC3YRCwJNbRzKtfFhJ3tfGHF4eNredVWQLfINxwGIbrw5wlyFw17FS dXbtDksydOg+iowWt7avfLblP/ohkffcTwocpwvk6Gd/PHV32AtS+oe/O8PiTDWMC7 O7JBLkX4Q9yjWJZ5HlfKvS8oK4DrioeVexT6qnyk= 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.4 291/320] parisc: pdc_stable: Fix memory leak in pdcs_register_pathentries Date: Mon, 24 Jan 2022 19:44:35 +0100 Message-Id: <20220124184003.848145150@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183953.750177707@linuxfoundation.org> References: <20220124183953.750177707@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);