From nobody Tue Dec 2 01:26:16 2025 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 455302BEC2C; Fri, 21 Nov 2025 16:46:56 +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=1763743616; cv=none; b=Ltu6VQCCiyHUE0h5s5dPZ+9M3CeE1+N3qbiIQ0ORPmuaUuud78FJXVRxNHD9Nfw5priD1lxkVdE8eb5I9YxvEm3fa22QhmvmcOjNfiz84XzKoa3JAGoEGGx1OQNuVNEdFLLw5boj0CCSo3BZBnGhPxtERF9RmDAowx6Owx0sUzU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763743616; c=relaxed/simple; bh=wO5VidB/EAiJ5mwgeHjepeP6B+fU37Eas6aRn/dc7+o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Wk/Z1whLMBBNA35baNKYwl9o3xS9DoDxcrdQv77qxrtHtrhMGhmGtGFvxIj2WAuK36SameLoWiVecVSrl+FcZ7fEyvfcZxXpvW2pyz1kx4rSGvdNiN/bbiMVyWlSGuEqw59/B9cLUhswn991Pkc26KvX80NsgI1vgIqD1TzZOF8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TvM81oRw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TvM81oRw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11331C4CEF1; Fri, 21 Nov 2025 16:46:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763743616; bh=wO5VidB/EAiJ5mwgeHjepeP6B+fU37Eas6aRn/dc7+o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TvM81oRwBZs+8ChD+xZR2nlor0dXwHrqQLLJTpxNfLs3bnDuBM7cgYdbVWlDobb4B gmE1d2bpmRqsrhzh6P89iYbcV5G1xg+DYuumFvaOcDqNODbb5f+Z7T3zJkuZR+ce1B flETduggsY/NU/jgFADtijKayf4OVC9Qy7Aa8h1phVlK3FyeCNvoptEcRs+XlYiydK hzwpJ+SWfNMVuLzmB9hrFhCfwkll1LACgVB+cFsxzAV2/oymkzSpf5FhQN/CLPTy0j FBhMfUEy7U+G6WVEh56qdJW5FVtWehvRbSo6r6KaaHNmi6zBYyJekaeNOI0baWBRp4 PB/Ixrpyd+wbw== Received: from johan by xi.lan with local (Exim 4.98.2) (envelope-from ) id 1vMUHh-000000003ZP-1idI; Fri, 21 Nov 2025 17:46:57 +0100 From: Johan Hovold To: Yong Wu , Krzysztof Kozlowski Cc: Matthias Brugger , AngeloGioacchino Del Regno , linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Miaoqian Lin Subject: [PATCH 1/3] memory: mtk-smi: fix device leaks on common probe Date: Fri, 21 Nov 2025 17:46:22 +0100 Message-ID: <20251121164624.13685-2-johan@kernel.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251121164624.13685-1-johan@kernel.org> References: <20251121164624.13685-1-johan@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Make sure to drop the reference taken when looking up the SMI device during common probe on late probe failure (e.g. probe deferral) and on driver unbind. Fixes: 47404757702e ("memory: mtk-smi: Add device link for smi-sub-common") Fixes: 038ae37c510f ("memory: mtk-smi: add missing put_device() call in mtk= _smi_device_link_common") Cc: stable@vger.kernel.org # 5.16: 038ae37c510f Cc: Yong Wu Cc: Miaoqian Lin Signed-off-by: Johan Hovold --- drivers/memory/mtk-smi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c index 733e22f695ab..dd6150d200e8 100644 --- a/drivers/memory/mtk-smi.c +++ b/drivers/memory/mtk-smi.c @@ -674,6 +674,7 @@ static int mtk_smi_larb_probe(struct platform_device *p= dev) err_pm_disable: pm_runtime_disable(dev); device_link_remove(dev, larb->smi_common_dev); + put_device(larb->smi_common_dev); return ret; } =20 @@ -917,6 +918,7 @@ static void mtk_smi_common_remove(struct platform_devic= e *pdev) if (common->plat->type =3D=3D MTK_SMI_GEN2_SUB_COMM) device_link_remove(&pdev->dev, common->smi_common_dev); pm_runtime_disable(&pdev->dev); + put_device(common->smi_common_dev); } =20 static int __maybe_unused mtk_smi_common_resume(struct device *dev) --=20 2.51.2 From nobody Tue Dec 2 01:26:16 2025 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 866732ED85D; Fri, 21 Nov 2025 16:46:56 +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=1763743616; cv=none; b=ETiuOBJmNg24vr7mh+lWB4wkVQV7KnY57bTK+CudZLUPw++x8qMRUvG/S/hg/WmCG/9IX0ar0tJ/Khym5AmkuL+SRx9kKNL1+uFt+g3ioFjVFBCT+JzAEDl6xO2RiqXEslTWqdINqZPOFoUnLC8lNzv71y9cA+iYKCMeaI108CY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763743616; c=relaxed/simple; bh=aVXKgdTVNhP4i1JEeKXE3HxQU0vhsNU0tGwaDb1blrU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UndW+7p3BOsBArVQo+tYiwCJi+lffiW0DURLm7Mo4G0hUVWyieBg5HeUZSDml311hsLbBXLl/YpssFJaidz/IB5yGDlJvx+Kvc1+/lg1qIWWmsFmPV8DBYO7JNizSbybUx/qvlIs2Ey5vuwgLeJX80/hYVkzVh89HcCMJFgXYeY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Qr8pjvgb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Qr8pjvgb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3BDD0C19423; Fri, 21 Nov 2025 16:46:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763743616; bh=aVXKgdTVNhP4i1JEeKXE3HxQU0vhsNU0tGwaDb1blrU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qr8pjvgbJKyX+UYd1vALWtKcUgng2r7Ve+VX31NpsgJabslvrLauyETtqlG0UyCa5 jxvsmL0VuOkP2BygUIdUNZd5fTsUNOdY6yflBydRC6jPbw7989NQAtjEylSWS/azR3 2Hj1IWc5XolMGho93lE4u2ylW59JttAhOl9+P/RyctCbO/bnwA0E3+a3I3KuDfAoaa 631aTYoWsQ9IvLZrBa5A+hwLFpBn4l+rpOgo5rWEHd3SSRDApE1jK6rwreiBbTCpmZ QirtBglGPAqF5fi+jb4NRoqPdpNLbSIr+KAmRGm44rsZ/OgvcCMq9DPDosPCWBIG7T wsxIou3k6L9Mw== Received: from johan by xi.lan with local (Exim 4.98.2) (envelope-from ) id 1vMUHh-000000003ZR-28Kr; Fri, 21 Nov 2025 17:46:57 +0100 From: Johan Hovold To: Yong Wu , Krzysztof Kozlowski Cc: Matthias Brugger , AngeloGioacchino Del Regno , linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Miaoqian Lin Subject: [PATCH 2/3] memory: mtk-smi: fix device leak on larb probe Date: Fri, 21 Nov 2025 17:46:23 +0100 Message-ID: <20251121164624.13685-3-johan@kernel.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251121164624.13685-1-johan@kernel.org> References: <20251121164624.13685-1-johan@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Make sure to drop the reference taken when looking up the SMI device during larb probe on late probe failure (e.g. probe deferral) and on driver unbind. Fixes: cc8bbe1a8312 ("memory: mediatek: Add SMI driver") Fixes: 038ae37c510f ("memory: mtk-smi: add missing put_device() call in mtk= _smi_device_link_common") Cc: stable@vger.kernel.org # 4.6: 038ae37c510f Cc: Yong Wu Cc: Miaoqian Lin Signed-off-by: Johan Hovold --- drivers/memory/mtk-smi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c index dd6150d200e8..3609bfd3c64b 100644 --- a/drivers/memory/mtk-smi.c +++ b/drivers/memory/mtk-smi.c @@ -685,6 +685,7 @@ static void mtk_smi_larb_remove(struct platform_device = *pdev) device_link_remove(&pdev->dev, larb->smi_common_dev); pm_runtime_disable(&pdev->dev); component_del(&pdev->dev, &mtk_smi_larb_component_ops); + put_device(larb->smi_common_dev); } =20 static int __maybe_unused mtk_smi_larb_resume(struct device *dev) --=20 2.51.2 From nobody Tue Dec 2 01:26:16 2025 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 8673D2EDD45 for ; Fri, 21 Nov 2025 16:46:56 +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=1763743616; cv=none; b=lqiFeJKGOXANpxLpXvavo6NysBPbByob5Bu4Yh9hwtaeQVYwPWRJGlBbF1bg/foL7tBP4RzQaTnxCXF0thcV2aDjy5RBAhz/OEBaPQzQQHiVUQ138l6AMrRb7nDYyH9k0xXbAvlxT4uOFAyrhfE7GlUSyjkzNMDMdEF0Q2O/1qk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763743616; c=relaxed/simple; bh=a40IkiU6xvqjxBkq9vQ37vCmt5+0t9lSnkk0qDk52Lc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=guiZSeP5uZ0df6bOjjL161hxILLWJTyM0GXzXk1yeGODEjosrBrn7ue+QmCg6o7OM4aKds6t3PDlamcsGmFhy09oQcureBU+dKUmoB3ZprL1i/Ff1Gd++DAQLpGoreG5uo9z04GWw0wRCTjgvccpnJRftfqxdtlGkP33weX4u0U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=O6VnLmeW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="O6VnLmeW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3BD10C19422; Fri, 21 Nov 2025 16:46:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763743616; bh=a40IkiU6xvqjxBkq9vQ37vCmt5+0t9lSnkk0qDk52Lc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O6VnLmeWZp24GSdjtF3oHTE3KCuOHk4p1ho6LiP5NydWyXcRI1obhWJ7W1YHb6jCa besem1XY1hJTPv3dUTEXrrCNqoS2B5ldARzovTOYKHZ0z8qMQa8kT+6Y3aXOseOwKp 0O51BVkYKwINyOdyTg5Y5xx3Rs82tfP4Q6cnfneORgE3KY/3XPDAvIPzbKqSnD/rk2 fNjzzYhRXVmgpi6kBVgMSXJBIyjjAoRqIG+F0Wpg7SWMup4RMVAA1/453ix0HNTGwf H0W5bIGFpV4th3yOHo4jM0evljHiK4dJh7wahpIKZ1NKMkEzoduI6aAVWXqP+xCmjo VnAkV7/zuFqgA== Received: from johan by xi.lan with local (Exim 4.98.2) (envelope-from ) id 1vMUHh-000000003ZU-2YXq; Fri, 21 Nov 2025 17:46:57 +0100 From: Johan Hovold To: Yong Wu , Krzysztof Kozlowski Cc: Matthias Brugger , AngeloGioacchino Del Regno , linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 3/3] memory: mtk-smi: clean up device link creation Date: Fri, 21 Nov 2025 17:46:24 +0100 Message-ID: <20251121164624.13685-4-johan@kernel.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251121164624.13685-1-johan@kernel.org> References: <20251121164624.13685-1-johan@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Clean up device link creation by bailing out early in case the SMI platform device lookup fails. Signed-off-by: Johan Hovold --- drivers/memory/mtk-smi.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c index 3609bfd3c64b..aaeba8ab211e 100644 --- a/drivers/memory/mtk-smi.c +++ b/drivers/memory/mtk-smi.c @@ -595,25 +595,28 @@ static int mtk_smi_device_link_common(struct device *= dev, struct device **com_de =20 smi_com_pdev =3D of_find_device_by_node(smi_com_node); of_node_put(smi_com_node); - if (smi_com_pdev) { - /* smi common is the supplier, Make sure it is ready before */ - if (!platform_get_drvdata(smi_com_pdev)) { - put_device(&smi_com_pdev->dev); - return -EPROBE_DEFER; - } - smi_com_dev =3D &smi_com_pdev->dev; - link =3D device_link_add(dev, smi_com_dev, - DL_FLAG_PM_RUNTIME | DL_FLAG_STATELESS); - if (!link) { - dev_err(dev, "Unable to link smi-common dev\n"); - put_device(&smi_com_pdev->dev); - return -ENODEV; - } - *com_dev =3D smi_com_dev; - } else { + if (!smi_com_pdev) { dev_err(dev, "Failed to get the smi_common device\n"); return -EINVAL; } + + /* smi common is the supplier, Make sure it is ready before */ + if (!platform_get_drvdata(smi_com_pdev)) { + put_device(&smi_com_pdev->dev); + return -EPROBE_DEFER; + } + + smi_com_dev =3D &smi_com_pdev->dev; + link =3D device_link_add(dev, smi_com_dev, + DL_FLAG_PM_RUNTIME | DL_FLAG_STATELESS); + if (!link) { + dev_err(dev, "Unable to link smi-common dev\n"); + put_device(&smi_com_pdev->dev); + return -ENODEV; + } + + *com_dev =3D smi_com_dev; + return 0; } =20 --=20 2.51.2