mmc: sdhci-xenon: kill xenon_clean_phy()
Subsystems (3)
PATCH 1/1 mmc: sdhci-xenon: kill xenon_clean_phy()
Currently, the xenon_clean_phy() is only used for freeing phy_params. The phy_params is allocated by devm_kzalloc(), there's no need to free is explicitly.
--- drivers/mmc/host/sdhci-xenon-phy.c | 14 +------------- drivers/mmc/host/sdhci-xenon.c | 6 +----- drivers/mmc/host/sdhci-xenon.h | 1 - 3 files changed, 2 insertions(+), 19 deletions(-)
drivers/mmc/host/sdhci-xenon-phy.c +1 -13
@@ -787,14 +787,6 @@ int xenon_phy_adj(struct sdhci_host *host, struct mmc_ios *ios)return ret; } -void xenon_clean_phy (struct sdhci_host *host) -{ -struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); -struct xenon_priv *priv =sdhci_pltfm_priv (pltfm_host); - -kfree (priv->phy_params); -} -static int xenon_add_phy (struct device_node *np,struct sdhci_host *host,const char *phy_name) {
@@ -819,11 +811,7 @@ static int xenon_add_phy(struct device_node *np, struct sdhci_host *host,if (ret)return ret; - ret =xenon_emmc_phy_parse_param_dt (host, np, priv->phy_params); -if (ret) -xenon_clean_phy (host); - -return ret; +return xenon_emmc_phy_parse_param_dt (host, np, priv->phy_params); }int xenon_phy_parse_dt (struct device_node *np,struct sdhci_host *host)
drivers/mmc/host/sdhci-xenon.c +1 -5
@@ -486,7 +486,7 @@ static int xenon_probe(struct platform_device *pdev) err =xenon_sdhc_prepare (host);if (err) - goto clean_phy_param; + goto err_clk; err =sdhci_add_host (host);if (err)
@@ -496,8 +496,6 @@ static int xenon_probe(struct platform_device *pdev) remove_sdhc:xenon_sdhc_unprepare (host); -clean_phy_param: -xenon_clean_phy (host); err_clk:clk_disable_unprepare (pltfm_host->clk); free_pltfm:
@@ -510,8 +508,6 @@ static int xenon_remove(struct platform_device *pdev)struct sdhci_host *host =platform_get_drvdata (pdev);struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); -xenon_clean_phy (host); -sdhci_remove_host (host,0 );xenon_sdhc_unprepare (host);
drivers/mmc/host/sdhci-xenon.h +0 -1
@@ -93,7 +93,6 @@ struct xenon_priv { };int xenon_phy_adj (struct sdhci_host *host,struct mmc_ios *ios); -void xenon_clean_phy (struct sdhci_host *host);int xenon_phy_parse_dt (struct device_node *np,struct sdhci_host *host); void xenon_soc_pad_ctrl(struct sdhci_host *host,
Signature · 1 line
2.11.0
Quoted 16 lines · Jisheng Zhang
Currently, the
xenon_clean_phy()is only used for freeingphy_params. Thephy_paramsis allocated bydevm_kzalloc(), there's no need to free is explicitly.Signed-off-by Jisheng Zhang <[email protected]>--- drivers/mmc/host/sdhci-xenon-phy.c | 14 +------------- drivers/mmc/host/sdhci-xenon.c | 6 +----- drivers/mmc/host/sdhci-xenon.h | 1 - 3 files changed, 2 insertions(+), 19 deletions(-)drivers/mmc/host/sdhci-xenon-phy.c +0
-0
drivers/mmc/host/sdhci-xenon-phy.c int xenon_phy_adj(struct sdhci_host *host, struct mmc_ios *ios) · line 795
Quoted 9 lines
drivers/mmc/host/sdhci-xenon-phy.c +0
-6@@ -787,14 +787,6 @@ int xenon_phy_adj(struct sdhci_host *host, struct mmc_ios *ios)return ret; } -void xenon_clean_phy (struct sdhci_host *host) -{ -struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); -struct xenon_priv *priv =sdhci_pltfm_priv (pltfm_host); - -kfree (priv->phy_params);
Hi Jisheng
If the memory has been allocated using the devm_ API, calling kfree here is wrong, and can lead to a double free.
So this patch should probably have a fixes: tag. Should it also goto stable?
Andrew
Quoted 5 lines · Andrew Lunn
If the memory has been allocated using the
devm_API, calling kfree here is wrong, and can lead to a double free.So this patch should probably have a fixes: tag. Should it also goto stable?
No, sdhci-xenon has only hit mainline during the recent merge window, so it's not in any kernel other than 4.12-rc1.
Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.
Quoted 20 lines · On Tue, 16 May 2017 14:22:11 +0200 Andrew Lunn wrote:
Quoted 19 lines · Jisheng Zhang
Currently, the
xenon_clean_phy()is only used for freeingphy_params. Thephy_paramsis allocated bydevm_kzalloc(), there's no need to free is explicitly.Signed-off-by Jisheng Zhang <[email protected]>--- drivers/mmc/host/sdhci-xenon-phy.c | 14 +------------- drivers/mmc/host/sdhci-xenon.c | 6 +----- drivers/mmc/host/sdhci-xenon.h | 1 - 3 files changed, 2 insertions(+), 19 deletions(-)drivers/mmc/host/sdhci-xenon-phy.c +0
-0@@ -787,14 +787,6 @@ int xenon_phy_adj(struct sdhci_host *host, struct mmc_ios *ios)return ret; }
Quoted 8 lines
drivers/mmc/host/sdhci-xenon-phy.c int xenon_phy_adj(struct sdhci_host *host, struct mmc_ios *ios) · line 795
Quoted 6 lines
drivers/mmc/host/sdhci-xenon-phy.c +0
-6-void xenon_clean_phy (struct sdhci_host *host) -{ -struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); -struct xenon_priv *priv =sdhci_pltfm_priv (pltfm_host); - -kfree (priv->phy_params);Hi Jisheng
Hi Andrew,
Quoted 3 lines
If the memory has been allocated using the
devm_API, calling kfree here is wrong, and can lead to a double free.
Yes. In fact, I found this issue by unbinding then binding the xenon host.
Quoted 3 lines
So this patch should probably have a fixes: tag. Should it also goto stable?
As pointed out by RMK, the sdhci-xenon driver is merged in current 4.12-rc1, so we just need to apply this fix in later rcN.
Thanks,
Jisheng
Quoted 2 lines
As pointed out by RMK, the sdhci-xenon driver is merged in current 4.12-rc1, so we just need to apply this fix in later rcN.
Yep. It helps the maintainer if you point this out in the patch, after the ---.
Andrew
Hu Ziji
maintainerQuoted 5 lines · Jisheng Zhang
Currently, the
xenon_clean_phy()is only used for freeingphy_params. Thephy_paramsis allocated bydevm_kzalloc(), there's no need to free is explicitly.Signed-off-by Jisheng Zhang <[email protected]>
Thanks for the fix.
Acked-by Hu Ziji <[email protected]>
Best regards,
Hu Ziji
Quoted 82 lines
--- drivers/mmc/host/sdhci-xenon-phy.c | 14 +------------- drivers/mmc/host/sdhci-xenon.c | 6 +----- drivers/mmc/host/sdhci-xenon.h | 1 - 3 files changed, 2 insertions(+), 19 deletions(-)drivers/mmc/host/sdhci-xenon-phy.c +1
-13@@ -787,14 +787,6 @@ int xenon_phy_adj(struct sdhci_host *host, struct mmc_ios *ios)return ret; } -void xenon_clean_phy (struct sdhci_host *host) -{ -struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); -struct xenon_priv *priv =sdhci_pltfm_priv (pltfm_host); - -kfree (priv->phy_params); -} -static int xenon_add_phy (struct device_node *np,struct sdhci_host *host,const char *phy_name) {@@ -819,11 +811,7 @@ static int xenon_add_phy(struct device_node *np, struct sdhci_host *host,if (ret)return ret; - ret =xenon_emmc_phy_parse_param_dt (host, np, priv->phy_params); -if (ret) -xenon_clean_phy (host); - -return ret; +return xenon_emmc_phy_parse_param_dt (host, np, priv->phy_params); }int xenon_phy_parse_dt (struct device_node *np,struct sdhci_host *host)drivers/mmc/host/sdhci-xenon.c +1
-5@@ -486,7 +486,7 @@ static int xenon_probe(struct platform_device *pdev) err =xenon_sdhc_prepare (host);if (err) - goto clean_phy_param; + goto err_clk; err =sdhci_add_host (host);if (err)@@ -496,8 +496,6 @@ static int xenon_probe(struct platform_device *pdev) remove_sdhc:xenon_sdhc_unprepare (host); -clean_phy_param: -xenon_clean_phy (host); err_clk:clk_disable_unprepare (pltfm_host->clk); free_pltfm:@@ -510,8 +508,6 @@ static int xenon_remove(struct platform_device *pdev)struct sdhci_host *host =platform_get_drvdata (pdev);struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); -xenon_clean_phy (host); -sdhci_remove_host (host,0 );xenon_sdhc_unprepare (host);drivers/mmc/host/sdhci-xenon.h +0
-1@@ -93,7 +93,6 @@ struct xenon_priv { };int xenon_phy_adj (struct sdhci_host *host,struct mmc_ios *ios); -void xenon_clean_phy (struct sdhci_host *host);int xenon_phy_parse_dt (struct device_node *np,struct sdhci_host *host); void xenon_soc_pad_ctrl(struct sdhci_host *host,
Quoted 5 lines · Jisheng Zhang
Currently, the
xenon_clean_phy()is only used for freeingphy_params. Thephy_paramsis allocated bydevm_kzalloc(), there's no need to free is explicitly.Signed-off-by Jisheng Zhang <[email protected]>
Ulf Hansson
AppliedQuoted 5 lines · Jisheng Zhang
Currently, the
xenon_clean_phy()is only used for freeingphy_params. Thephy_paramsis allocated bydevm_kzalloc(), there's no need to free is explicitly.Signed-off-by Jisheng Zhang <[email protected]>
Thanks, applied for fixes!
Kind regards
Uffe
Quoted 84 lines
--- drivers/mmc/host/sdhci-xenon-phy.c | 14 +------------- drivers/mmc/host/sdhci-xenon.c | 6 +----- drivers/mmc/host/sdhci-xenon.h | 1 - 3 files changed, 2 insertions(+), 19 deletions(-)drivers/mmc/host/sdhci-xenon-phy.c +1
-13@@ -787,14 +787,6 @@ int xenon_phy_adj(struct sdhci_host *host, struct mmc_ios *ios)return ret; } -void xenon_clean_phy (struct sdhci_host *host) -{ -struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); -struct xenon_priv *priv =sdhci_pltfm_priv (pltfm_host); - -kfree (priv->phy_params); -} -static int xenon_add_phy (struct device_node *np,struct sdhci_host *host,const char *phy_name) {@@ -819,11 +811,7 @@ static int xenon_add_phy(struct device_node *np, struct sdhci_host *host,if (ret)return ret; - ret =xenon_emmc_phy_parse_param_dt (host, np, priv->phy_params); -if (ret) -xenon_clean_phy (host); - -return ret; +return xenon_emmc_phy_parse_param_dt (host, np, priv->phy_params); }int xenon_phy_parse_dt (struct device_node *np,struct sdhci_host *host)drivers/mmc/host/sdhci-xenon.c +1
-5@@ -486,7 +486,7 @@ static int xenon_probe(struct platform_device *pdev) err =xenon_sdhc_prepare (host);if (err) - goto clean_phy_param; + goto err_clk; err =sdhci_add_host (host);if (err)@@ -496,8 +496,6 @@ static int xenon_probe(struct platform_device *pdev) remove_sdhc:xenon_sdhc_unprepare (host); -clean_phy_param: -xenon_clean_phy (host); err_clk:clk_disable_unprepare (pltfm_host->clk); free_pltfm:@@ -510,8 +508,6 @@ static int xenon_remove(struct platform_device *pdev)struct sdhci_host *host =platform_get_drvdata (pdev);struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); -xenon_clean_phy (host); -sdhci_remove_host (host,0 );xenon_sdhc_unprepare (host);drivers/mmc/host/sdhci-xenon.h +0
-2@@ -93,7 +93,6 @@ struct xenon_priv { };int xenon_phy_adj (struct sdhci_host *host,struct mmc_ios *ios); -void xenon_clean_phy (struct sdhci_host *host);int xenon_phy_parse_dt (struct device_node *np,struct sdhci_host *host); void xenon_soc_pad_ctrl(struct sdhci_host *host, --2.11.0