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 DB4F717C995; Thu, 15 Aug 2024 14:32:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723732340; cv=none; b=cYpjV7MNlI/E7kcVdRJqask6aEF8pwYxhFvmxDxtYCdGlhbFIkh9NVoUvvAULPvjk5yPWs0IANZVP7/gr4g4whtnLD664zx4Tfcd8rD5cEkTFD7t64I737jrLJFIxNVmAySmMVRxqqheekVxuCtXvvjEWE7czidtlseRswOnPXQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723732340; c=relaxed/simple; bh=UZtSmUllBXqOcwWsDo4al+3DY9tzYYKfVVWFV91LdUU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pevy6AC6jW1D8ysUp6LJ1zNY5Vv+ENjQkiE+fV4raqPyI5FeJBGw8niWzqa1i+JfZY9q6AHumpBIxgFXCjiOjZJi3uFMz5XKWhoC6ie3WUf8EcWDU5xVSvrEn4BHgcDNA10ugEMcOJek1ukt/ap57IaPuivWtxx9pg6LYWNvN1c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=rpWLlN1L; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="rpWLlN1L" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0032DC32786; Thu, 15 Aug 2024 14:32:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1723732339; bh=UZtSmUllBXqOcwWsDo4al+3DY9tzYYKfVVWFV91LdUU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rpWLlN1LU5DFhimPqF7LunscT3/7/cUslG2bLro1nXcJHxXXsrEFz13d+ZB7DugRB ACVjL87klS2sc6dJ/to1xNHR+anwPCdNJP8nl1ElfHXBL5DXWEXimMagUe+7qbFq/D yieG5rWh/AEUdFpe87vGVz+I/yTjw9SY0siUsY7s= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yang Yingliang , Dan Carpenter , Linus Walleij , Sasha Levin Subject: [PATCH 5.10 118/352] pinctrl: ti: ti-iodelay: fix possible memory leak when pinctrl_enable() fails Date: Thu, 15 Aug 2024 15:23:04 +0200 Message-ID: <20240815131923.815094087@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240815131919.196120297@linuxfoundation.org> References: <20240815131919.196120297@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yang Yingliang [ Upstream commit 9b401f4a7170125365160c9af267a41ff6b39001 ] This driver calls pinctrl_register_and_init() which is not devm_ managed, it will leads memory leak if pinctrl_enable() fails. Replace it with devm_pinctrl_register_and_init(). And add missing of_node_put() in the error path. Fixes: 5038a66dad01 ("pinctrl: core: delete incorrect free in pinctrl_enable()") Signed-off-by: Yang Yingliang Reviewed-by: Dan Carpenter Link: https://lore.kernel.org/r/20240606023704.3931561-4-yangyingliang@huawei.com Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin --- drivers/pinctrl/ti/pinctrl-ti-iodelay.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c b/drivers/pinctrl/ti/pinctrl-ti-iodelay.c index 60d94c1fc6a6d..6e1b067fb72ed 100644 --- a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c +++ b/drivers/pinctrl/ti/pinctrl-ti-iodelay.c @@ -881,7 +881,7 @@ static int ti_iodelay_probe(struct platform_device *pdev) iod->desc.name = dev_name(dev); iod->desc.owner = THIS_MODULE; - ret = pinctrl_register_and_init(&iod->desc, dev, iod, &iod->pctl); + ret = devm_pinctrl_register_and_init(dev, &iod->desc, iod, &iod->pctl); if (ret) { dev_err(dev, "Failed to register pinctrl\n"); goto exit_out; @@ -889,7 +889,11 @@ static int ti_iodelay_probe(struct platform_device *pdev) platform_set_drvdata(pdev, iod); - return pinctrl_enable(iod->pctl); + ret = pinctrl_enable(iod->pctl); + if (ret) + goto exit_out; + + return 0; exit_out: of_node_put(np); @@ -906,9 +910,6 @@ static int ti_iodelay_remove(struct platform_device *pdev) { struct ti_iodelay_device *iod = platform_get_drvdata(pdev); - if (iod->pctl) - pinctrl_unregister(iod->pctl); - ti_iodelay_pinconf_deinit_dev(iod); /* Expect other allocations to be freed by devm */ -- 2.43.0