Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

phy: qcom-qmp-ufs: fix memleak on probe deferral

Switch to using the device-managed of_iomap helper to avoid leaking
memory on probe deferral and driver unbind.

Note that this helper checks for already reserved regions and may fail
if there are multiple devices claiming the same memory.

Fixes: e78f3d15e115 ("phy: qcom-qmp: new qmp phy driver for qcom-chipsets")
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Link: https://lore.kernel.org/r/20220916102340.11520-6-johan+linaro@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Johan Hovold and committed by
Vinod Koul
ef74a97f 2de8a325

+15 -15
+15 -15
drivers/phy/qualcomm/phy-qcom-qmp-ufs.c
··· 1125 1125 * For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5 1126 1126 * For single lane PHYs: pcs_misc (optional) -> 3. 1127 1127 */ 1128 - qphy->tx = of_iomap(np, 0); 1129 - if (!qphy->tx) 1130 - return -ENOMEM; 1128 + qphy->tx = devm_of_iomap(dev, np, 0, NULL); 1129 + if (IS_ERR(qphy->tx)) 1130 + return PTR_ERR(qphy->tx); 1131 1131 1132 - qphy->rx = of_iomap(np, 1); 1133 - if (!qphy->rx) 1134 - return -ENOMEM; 1132 + qphy->rx = devm_of_iomap(dev, np, 1, NULL); 1133 + if (IS_ERR(qphy->rx)) 1134 + return PTR_ERR(qphy->rx); 1135 1135 1136 - qphy->pcs = of_iomap(np, 2); 1137 - if (!qphy->pcs) 1138 - return -ENOMEM; 1136 + qphy->pcs = devm_of_iomap(dev, np, 2, NULL); 1137 + if (IS_ERR(qphy->pcs)) 1138 + return PTR_ERR(qphy->pcs); 1139 1139 1140 1140 /* 1141 1141 * If this is a dual-lane PHY, then there should be registers for the ··· 1144 1144 * offset from the first lane. 1145 1145 */ 1146 1146 if (cfg->is_dual_lane_phy) { 1147 - qphy->tx2 = of_iomap(np, 3); 1148 - qphy->rx2 = of_iomap(np, 4); 1149 - if (!qphy->tx2 || !qphy->rx2) { 1147 + qphy->tx2 = devm_of_iomap(dev, np, 3, NULL); 1148 + qphy->rx2 = devm_of_iomap(dev, np, 4, NULL); 1149 + if (IS_ERR(qphy->tx2) || IS_ERR(qphy->rx2)) { 1150 1150 dev_warn(dev, 1151 1151 "Underspecified device tree, falling back to legacy register regions\n"); 1152 1152 ··· 1156 1156 qphy->rx2 = qphy->rx + QMP_PHY_LEGACY_LANE_STRIDE; 1157 1157 1158 1158 } else { 1159 - qphy->pcs_misc = of_iomap(np, 5); 1159 + qphy->pcs_misc = devm_of_iomap(dev, np, 5, NULL); 1160 1160 } 1161 1161 1162 1162 } else { 1163 - qphy->pcs_misc = of_iomap(np, 3); 1163 + qphy->pcs_misc = devm_of_iomap(dev, np, 3, NULL); 1164 1164 } 1165 1165 1166 - if (!qphy->pcs_misc) 1166 + if (IS_ERR(qphy->pcs_misc)) 1167 1167 dev_vdbg(dev, "PHY pcs_misc-reg not used\n"); 1168 1168 1169 1169 generic_phy = devm_phy_create(dev, np, &qcom_qmp_ufs_ops);