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-combo: 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-5-johan+linaro@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Johan Hovold and committed by
Vinod Koul
2de8a325 1f69eded

+17 -15
+17 -15
drivers/phy/qualcomm/phy-qcom-qmp-combo.c
··· 2714 2714 * For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5 2715 2715 * For single lane PHYs: pcs_misc (optional) -> 3. 2716 2716 */ 2717 - qphy->tx = of_iomap(np, 0); 2718 - if (!qphy->tx) 2719 - return -ENOMEM; 2717 + qphy->tx = devm_of_iomap(dev, np, 0, NULL); 2718 + if (IS_ERR(qphy->tx)) 2719 + return PTR_ERR(qphy->tx); 2720 2720 2721 - qphy->rx = of_iomap(np, 1); 2722 - if (!qphy->rx) 2723 - return -ENOMEM; 2721 + qphy->rx = devm_of_iomap(dev, np, 1, NULL); 2722 + if (IS_ERR(qphy->rx)) 2723 + return PTR_ERR(qphy->rx); 2724 2724 2725 - qphy->pcs = of_iomap(np, 2); 2726 - if (!qphy->pcs) 2727 - return -ENOMEM; 2725 + qphy->pcs = devm_of_iomap(dev, np, 2, NULL); 2726 + if (IS_ERR(qphy->pcs)) 2727 + return PTR_ERR(qphy->pcs); 2728 2728 2729 2729 if (cfg->pcs_usb_offset) 2730 2730 qphy->pcs_usb = qphy->pcs + cfg->pcs_usb_offset; ··· 2736 2736 * offset from the first lane. 2737 2737 */ 2738 2738 if (cfg->is_dual_lane_phy) { 2739 - qphy->tx2 = of_iomap(np, 3); 2740 - qphy->rx2 = of_iomap(np, 4); 2741 - if (!qphy->tx2 || !qphy->rx2) { 2739 + qphy->tx2 = devm_of_iomap(dev, np, 3, NULL); 2740 + qphy->rx2 = devm_of_iomap(dev, np, 4, NULL); 2741 + if (IS_ERR(qphy->tx2) || IS_ERR(qphy->rx2)) { 2742 2742 dev_warn(dev, 2743 2743 "Underspecified device tree, falling back to legacy register regions\n"); 2744 2744 ··· 2748 2748 qphy->rx2 = qphy->rx + QMP_PHY_LEGACY_LANE_STRIDE; 2749 2749 2750 2750 } else { 2751 - qphy->pcs_misc = of_iomap(np, 5); 2751 + qphy->pcs_misc = devm_of_iomap(dev, np, 5, NULL); 2752 2752 } 2753 2753 2754 2754 } else { 2755 - qphy->pcs_misc = of_iomap(np, 3); 2755 + qphy->pcs_misc = devm_of_iomap(dev, np, 3, NULL); 2756 2756 } 2757 2757 2758 - if (!qphy->pcs_misc) 2758 + if (IS_ERR(qphy->pcs_misc)) { 2759 2759 dev_vdbg(dev, "PHY pcs_misc-reg not used\n"); 2760 + qphy->pcs_misc = NULL; 2761 + } 2760 2762 2761 2763 /* 2762 2764 * Get PHY's Pipe clock, if any. USB3 and PCIe are PIPE3