diff mbox series

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

Message ID 20220621065259.4079817-1-windhl@126.com
State New
Headers show
Series mmc/host/sdhci-of-esdhc: Hold a reference returned by of_find_compatible_node | expand

Commit Message

Liang He June 21, 2022, 6:52 a.m. UTC
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.

Signed-off-by: Liang He <windhl@126.com>
---
 drivers/mmc/host/sdhci-of-esdhc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Adrian Hunter June 22, 2022, 8:43 a.m. UTC | #1
On 21/06/22 09:52, Liang He wrote:
> 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.
> 
> Signed-off-by: Liang He <windhl@126.com>

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  drivers/mmc/host/sdhci-of-esdhc.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
> index d9dc41143bb3..9c8cd8b63578 100644
> --- a/drivers/mmc/host/sdhci-of-esdhc.c
> +++ b/drivers/mmc/host/sdhci-of-esdhc.c
> @@ -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;
>  	}
Ulf Hansson June 23, 2022, 1:09 p.m. UTC | #2
On Tue, 21 Jun 2022 at 08:53, Liang He <windhl@126.com> wrote:
>
> 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.
>
> Signed-off-by: Liang He <windhl@126.com>

Applied for next, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/host/sdhci-of-esdhc.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
> index d9dc41143bb3..9c8cd8b63578 100644
> --- a/drivers/mmc/host/sdhci-of-esdhc.c
> +++ b/drivers/mmc/host/sdhci-of-esdhc.c
> @@ -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
>
diff mbox series

Patch

diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
index d9dc41143bb3..9c8cd8b63578 100644
--- a/drivers/mmc/host/sdhci-of-esdhc.c
+++ b/drivers/mmc/host/sdhci-of-esdhc.c
@@ -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;
 	}