Skip to contentSkip to conversation

mmc/host/sdhci-of-esdhc: Hold a reference returned by of_find_compatible_node

PATCH In review Liang He 3 participants 3 messages Jun 21, 2022 – Jun 23, 2022

Subsystems (2)
lore
Share & tools
lore

Liang He

author
#0 lore raw

PATCH 1/1 mmc/host/sdhci-of-esdhc: Hold a reference returned by of_find_compatible_node

In sdhci_esdhc_probe(), we should hold the reference returned by of_find_compatible_node() which is used to of_node_put() for keep refcount balance.

---
 drivers/mmc/host/sdhci-of-esdhc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-of-esdhc.c +4 -2
index d9dc41143bb3..9c8cd8b63578 100644
@@ -1418,7 +1418,7 @@ static int esdhc_hs400_prepare_ddr(struct mmc_host *mmc)
 static int sdhci_esdhc_probe(struct platform_device *pdev)
 {
 	struct sdhci_host *host;
-	struct device_node *np;
+	struct device_node *np, *tp;
 	struct sdhci_pltfm_host *pltfm_host;
 	struct sdhci_esdhc *esdhc;
 	int ret;
@@ -1463,7 +1463,9 @@ static int sdhci_esdhc_probe(struct platform_device *pdev)
 	if (esdhc->vendor_ver > VENDOR_V_22)
 		host->quirks &= ~SDHCI_QUIRK_NO_BUSY_IRQ;
 
-	if (of_find_compatible_node(NULL, NULL, "fsl,p2020-esdhc")) {
+	tp = of_find_compatible_node(NULL, NULL, "fsl,p2020-esdhc");
+	if (tp) {
+		of_node_put(tp);
 		host->quirks |= SDHCI_QUIRK_RESET_AFTER_REQUEST;
 		host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
 	}
Signature · 1 line
2.25.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Liang He

In sdhci_esdhc_probe(), we should hold the reference returned by of_find_compatible_node() which is used to of_node_put() for keep refcount balance.

Quoted 28 lines
---
 drivers/mmc/host/sdhci-of-esdhc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-of-esdhc.c +4 -2
index d9dc41143bb3..9c8cd8b63578 100644
@@ -1418,7 +1418,7 @@ static int esdhc_hs400_prepare_ddr(struct mmc_host *mmc)
 static int sdhci_esdhc_probe(struct platform_device *pdev)
 {
 	struct sdhci_host *host;
-	struct device_node *np;
+	struct device_node *np, *tp;
 	struct sdhci_pltfm_host *pltfm_host;
 	struct sdhci_esdhc *esdhc;
 	int ret;
@@ -1463,7 +1463,9 @@ static int sdhci_esdhc_probe(struct platform_device *pdev)
 	if (esdhc->vendor_ver > VENDOR_V_22)
 		host->quirks &= ~SDHCI_QUIRK_NO_BUSY_IRQ;
 
-	if (of_find_compatible_node(NULL, NULL, "fsl,p2020-esdhc")) {
+	tp = of_find_compatible_node(NULL, NULL, "fsl,p2020-esdhc");
+	if (tp) {
+		of_node_put(tp);
 		host->quirks |= SDHCI_QUIRK_RESET_AFTER_REQUEST;
 		host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
 	}
#2 lore raw
In reply to Liang He
Quoted 6 lines · Liang He

In sdhci_esdhc_probe(), we should hold the reference returned by of_find_compatible_node() which is used to of_node_put() for keep refcount balance.

Applied for next, thanks!

Kind regards
Uffe

Quoted 31 lines
---
 drivers/mmc/host/sdhci-of-esdhc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-of-esdhc.c +4 -3
index d9dc41143bb3..9c8cd8b63578 100644
@@ -1418,7 +1418,7 @@ static int esdhc_hs400_prepare_ddr(struct mmc_host *mmc)
 static int sdhci_esdhc_probe(struct platform_device *pdev)
 {
        struct sdhci_host *host;
-       struct device_node *np;
+       struct device_node *np, *tp;
        struct sdhci_pltfm_host *pltfm_host;
        struct sdhci_esdhc *esdhc;
        int ret;
@@ -1463,7 +1463,9 @@ static int sdhci_esdhc_probe(struct platform_device *pdev)
        if (esdhc->vendor_ver > VENDOR_V_22)
                host->quirks &= ~SDHCI_QUIRK_NO_BUSY_IRQ;
 
-       if (of_find_compatible_node(NULL, NULL, "fsl,p2020-esdhc")) {
+       tp = of_find_compatible_node(NULL, NULL, "fsl,p2020-esdhc");
+       if (tp) {
+               of_node_put(tp);
                host->quirks |= SDHCI_QUIRK_RESET_AFTER_REQUEST;
                host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
        }
--

2.25.1