diff mbox series

[-next] mmc: core: fix return value check in devm_mmc_alloc_host()

Message ID 20230217024333.4018279-1-yangyingliang@huawei.com (mailing list archive)
State New, archived
Headers show
Series [-next] mmc: core: fix return value check in devm_mmc_alloc_host() | expand

Commit Message

Yang Yingliang Feb. 17, 2023, 2:43 a.m. UTC
mmc_alloc_host() returns NULL pointer not PTR_ERR(), if it
fails, so replace the IS_ERR() check with NULL pointer check.

In commit 418f7c2de133 ("mmc: meson-gx: use devm_mmc_alloc_host"),
it checks NULL pointer not PTR_ERR, if devm_mmc_alloc_host() fails,
so make it to return NULL pointer to keep same with mmc_alloc_host(),
the drivers don't need to change the error handle when switch to
use devm_mmc_alloc_host().

Fixes: 80df83c2c57e ("mmc: core: add devm_mmc_alloc_host")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/mmc/core/host.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Heiner Kallweit Feb. 17, 2023, 6:20 a.m. UTC | #1
On 17.02.2023 03:43, Yang Yingliang wrote:
> mmc_alloc_host() returns NULL pointer not PTR_ERR(), if it
> fails, so replace the IS_ERR() check with NULL pointer check.
> 
> In commit 418f7c2de133 ("mmc: meson-gx: use devm_mmc_alloc_host"),
> it checks NULL pointer not PTR_ERR, if devm_mmc_alloc_host() fails,
> so make it to return NULL pointer to keep same with mmc_alloc_host(),
> the drivers don't need to change the error handle when switch to
> use devm_mmc_alloc_host().
> 
> Fixes: 80df83c2c57e ("mmc: core: add devm_mmc_alloc_host")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---

Right, my bad.

Reviewed-by: Heiner Kallweit <hkallweit1@gmail.com>


>  drivers/mmc/core/host.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
> index 6a7475ad7685..096093f7be00 100644
> --- a/drivers/mmc/core/host.c
> +++ b/drivers/mmc/core/host.c
> @@ -599,12 +599,12 @@ struct mmc_host *devm_mmc_alloc_host(struct device *dev, int extra)
>  
>  	dr = devres_alloc(devm_mmc_host_release, sizeof(*dr), GFP_KERNEL);
>  	if (!dr)
> -		return ERR_PTR(-ENOMEM);
> +		return NULL;
>  
>  	host = mmc_alloc_host(extra, dev);
> -	if (IS_ERR(host)) {
> +	if (!host) {
>  		devres_free(dr);
> -		return host;
> +		return NULL;
>  	}
>  
>  	*dr = host;
Ulf Hansson Feb. 17, 2023, 10:29 a.m. UTC | #2
On Fri, 17 Feb 2023 at 03:44, Yang Yingliang <yangyingliang@huawei.com> wrote:
>
> mmc_alloc_host() returns NULL pointer not PTR_ERR(), if it
> fails, so replace the IS_ERR() check with NULL pointer check.
>
> In commit 418f7c2de133 ("mmc: meson-gx: use devm_mmc_alloc_host"),
> it checks NULL pointer not PTR_ERR, if devm_mmc_alloc_host() fails,
> so make it to return NULL pointer to keep same with mmc_alloc_host(),
> the drivers don't need to change the error handle when switch to
> use devm_mmc_alloc_host().
>
> Fixes: 80df83c2c57e ("mmc: core: add devm_mmc_alloc_host")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>

Applied for next, thanks!

Kind regards
Uffe

> ---
>  drivers/mmc/core/host.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
> index 6a7475ad7685..096093f7be00 100644
> --- a/drivers/mmc/core/host.c
> +++ b/drivers/mmc/core/host.c
> @@ -599,12 +599,12 @@ struct mmc_host *devm_mmc_alloc_host(struct device *dev, int extra)
>
>         dr = devres_alloc(devm_mmc_host_release, sizeof(*dr), GFP_KERNEL);
>         if (!dr)
> -               return ERR_PTR(-ENOMEM);
> +               return NULL;
>
>         host = mmc_alloc_host(extra, dev);
> -       if (IS_ERR(host)) {
> +       if (!host) {
>                 devres_free(dr);
> -               return host;
> +               return NULL;
>         }
>
>         *dr = host;
> --
> 2.25.1
>
diff mbox series

Patch

diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 6a7475ad7685..096093f7be00 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -599,12 +599,12 @@  struct mmc_host *devm_mmc_alloc_host(struct device *dev, int extra)
 
 	dr = devres_alloc(devm_mmc_host_release, sizeof(*dr), GFP_KERNEL);
 	if (!dr)
-		return ERR_PTR(-ENOMEM);
+		return NULL;
 
 	host = mmc_alloc_host(extra, dev);
-	if (IS_ERR(host)) {
+	if (!host) {
 		devres_free(dr);
-		return host;
+		return NULL;
 	}
 
 	*dr = host;