diff mbox series

[-next] power: supply: mt6370: Fix return value check in mt6370_chg_probe()

Message ID 20220921152915.1506767-1-yangyingliang@huawei.com
State Accepted
Commit 5738d49fa47e0046050f5e62e4921d667b7ee3c3
Headers show
Series [-next] power: supply: mt6370: Fix return value check in mt6370_chg_probe() | expand

Commit Message

Yang Yingliang Sept. 21, 2022, 3:29 p.m. UTC
If create_singlethread_workqueue() fails, it returns a null pointer,
replace IS_ERR() check with NULL pointer check.

Fixes: 233cb8a47d65 ("power: supply: mt6370: Add MediaTek MT6370 charger driver")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/power/supply/mt6370-charger.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

ChiaEn Wu Sept. 22, 2022, 1:42 a.m. UTC | #1
On 9/21/2022 11:29 PM, Yang Yingliang wrote:
> If create_singlethread_workqueue() fails, it returns a null pointer,
> replace IS_ERR() check with NULL pointer check.
> 
> Fixes: 233cb8a47d65 ("power: supply: mt6370: Add MediaTek MT6370 charger driver")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>   drivers/power/supply/mt6370-charger.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/power/supply/mt6370-charger.c b/drivers/power/supply/mt6370-charger.c
> index 716cba259a7a..f27dae5043f5 100644
> --- a/drivers/power/supply/mt6370-charger.c
> +++ b/drivers/power/supply/mt6370-charger.c
> @@ -911,8 +911,8 @@ static int mt6370_chg_probe(struct platform_device *pdev)
>   	priv->attach = MT6370_ATTACH_STAT_DETACH;
>   
>   	priv->wq = create_singlethread_workqueue(dev_name(priv->dev));
> -	if (IS_ERR(priv->wq))
> -		return dev_err_probe(dev, PTR_ERR(priv->wq),
> +	if (!priv->wq)
> +		return dev_err_probe(dev, -ENOMEM,
>   				     "Failed to create workqueue\n");
>   
>   	ret = devm_add_action_or_reset(dev, mt6370_chg_destroy_wq, priv->wq);

Hi Yingliang,

In general this looks good to me. Thanks for catching this!

Reviewed-by: ChiaEn Wu <chiaen_wu@richtek.com>
AngeloGioacchino Del Regno Sept. 22, 2022, 7:25 a.m. UTC | #2
Il 21/09/22 17:29, Yang Yingliang ha scritto:
> If create_singlethread_workqueue() fails, it returns a null pointer,
> replace IS_ERR() check with NULL pointer check.
> 
> Fixes: 233cb8a47d65 ("power: supply: mt6370: Add MediaTek MT6370 charger driver")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> Reviewed-by: ChiaEn Wu <chiaen_wu@richtek.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Sebastian Reichel Oct. 1, 2022, 8:22 p.m. UTC | #3
Hi,

On Wed, Sep 21, 2022 at 11:29:15PM +0800, Yang Yingliang wrote:
> If create_singlethread_workqueue() fails, it returns a null pointer,
> replace IS_ERR() check with NULL pointer check.
> 
> Fixes: 233cb8a47d65 ("power: supply: mt6370: Add MediaTek MT6370 charger driver")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>  drivers/power/supply/mt6370-charger.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/power/supply/mt6370-charger.c b/drivers/power/supply/mt6370-charger.c
> index 716cba259a7a..f27dae5043f5 100644
> --- a/drivers/power/supply/mt6370-charger.c
> +++ b/drivers/power/supply/mt6370-charger.c
> @@ -911,8 +911,8 @@ static int mt6370_chg_probe(struct platform_device *pdev)
>  	priv->attach = MT6370_ATTACH_STAT_DETACH;
>  
>  	priv->wq = create_singlethread_workqueue(dev_name(priv->dev));
> -	if (IS_ERR(priv->wq))
> -		return dev_err_probe(dev, PTR_ERR(priv->wq),
> +	if (!priv->wq)
> +		return dev_err_probe(dev, -ENOMEM,
>  				     "Failed to create workqueue\n");
>  
>  	ret = devm_add_action_or_reset(dev, mt6370_chg_destroy_wq, priv->wq);

Thanks, queued.

-- Sebastian
diff mbox series

Patch

diff --git a/drivers/power/supply/mt6370-charger.c b/drivers/power/supply/mt6370-charger.c
index 716cba259a7a..f27dae5043f5 100644
--- a/drivers/power/supply/mt6370-charger.c
+++ b/drivers/power/supply/mt6370-charger.c
@@ -911,8 +911,8 @@  static int mt6370_chg_probe(struct platform_device *pdev)
 	priv->attach = MT6370_ATTACH_STAT_DETACH;
 
 	priv->wq = create_singlethread_workqueue(dev_name(priv->dev));
-	if (IS_ERR(priv->wq))
-		return dev_err_probe(dev, PTR_ERR(priv->wq),
+	if (!priv->wq)
+		return dev_err_probe(dev, -ENOMEM,
 				     "Failed to create workqueue\n");
 
 	ret = devm_add_action_or_reset(dev, mt6370_chg_destroy_wq, priv->wq);