From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD9D37E for ; Wed, 2 Nov 2022 03:18:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E09E8C433C1; Wed, 2 Nov 2022 03:18:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1667359116; bh=6plsFg9FFZ4qHwbWBvnCQunJuOxbZy5rjeQicua/9Ks=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d3OHffCrDz0SrrG8nLZiFG0wE7F0t07+E3AWkMZxbjzW8u+TuOBch+Tw53V+zL9Sq ViBa6LiLF2isnXp66vsmMe5i45vwhMr1Yvkk4ZlZ8bC9MGphsN8Buf6lJcUqKt87Iy G2Pf9cGs+E/AvTySU0rmOEuuFR/MNLSqMStsglqY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yang Yingliang , Paolo Abeni , Sasha Levin Subject: [PATCH 5.10 79/91] net: ehea: fix possible memory leak in ehea_register_port() Date: Wed, 2 Nov 2022 03:34:02 +0100 Message-Id: <20221102022057.298139692@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102022055.039689234@linuxfoundation.org> References: <20221102022055.039689234@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Yang Yingliang [ Upstream commit 0e7ce23a917a9cc83ca3c779fbba836bca3bcf1e ] If of_device_register() returns error, the of node and the name allocated in dev_set_name() is leaked, call put_device() to give up the reference that was set in device_initialize(), so that of node is put in logical_port_release() and the name is freed in kobject_cleanup(). Fixes: 1acf2318dd13 ("ehea: dynamic add / remove port") Signed-off-by: Yang Yingliang Link: https://lore.kernel.org/r/20221025130011.1071357-1-yangyingliang@huawei.com Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- drivers/net/ethernet/ibm/ehea/ehea_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/ibm/ehea/ehea_main.c b/drivers/net/ethernet/ibm/ehea/ehea_main.c index f63066736425..28a5f8d73a61 100644 --- a/drivers/net/ethernet/ibm/ehea/ehea_main.c +++ b/drivers/net/ethernet/ibm/ehea/ehea_main.c @@ -2897,6 +2897,7 @@ static struct device *ehea_register_port(struct ehea_port *port, ret = of_device_register(&port->ofdev); if (ret) { pr_err("failed to register device. ret=%d\n", ret); + put_device(&port->ofdev.dev); goto out; } -- 2.35.1