linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] pinctrl: mediatek: moore: fix return value check in mtk_moore_pinctrl_probe()
@ 2018-09-20  6:21 Wei Yongjun
  2018-09-21  2:01 ` Sean Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Wei Yongjun @ 2018-09-20  6:21 UTC (permalink / raw)
  To: Linus Walleij, Matthias Brugger, Sean Wang, Ryder.Lee
  Cc: linux-gpio, kernel-janitors, linux-mediatek, Wei Yongjun,
	linux-arm-kernel

In case of error, the function devm_kmalloc_array() returns NULL pointer
not ERR_PTR(). The IS_ERR() test in the return value check should be
replaced with NULL test.

Fixes: b7d7f9eeca55 ("pinctrl: mediatek: extend struct mtk_pin_desc which per-pin driver depends on")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/pinctrl/mediatek/pinctrl-moore.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/pinctrl/mediatek/pinctrl-moore.c b/drivers/pinctrl/mediatek/pinctrl-moore.c
index c27597c..3bf5dd5 100644
--- a/drivers/pinctrl/mediatek/pinctrl-moore.c
+++ b/drivers/pinctrl/mediatek/pinctrl-moore.c
@@ -608,8 +608,8 @@ int mtk_moore_pinctrl_probe(struct platform_device *pdev,
 
 	hw->base = devm_kmalloc_array(&pdev->dev, hw->soc->nbase_names,
 				      sizeof(*hw->base), GFP_KERNEL);
-	if (IS_ERR(hw->base))
-		return PTR_ERR(hw->base);
+	if (!hw->base)
+		return -ENOMEM;
 
 	for (i = 0; i < hw->soc->nbase_names; i++) {
 		res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
@@ -629,8 +629,8 @@ int mtk_moore_pinctrl_probe(struct platform_device *pdev,
 	/* Copy from internal struct mtk_pin_desc to register to the core */
 	pins = devm_kmalloc_array(&pdev->dev, hw->soc->npins, sizeof(*pins),
 				  GFP_KERNEL);
-	if (IS_ERR(pins))
-		return PTR_ERR(pins);
+	if (!pins)
+		return -ENOMEM;
 
 	for (i = 0; i < hw->soc->npins; i++) {
 		pins[i].number = hw->soc->pins[i].number;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH -next] pinctrl: mediatek: moore: fix return value check in mtk_moore_pinctrl_probe()
  2018-09-20  6:21 [PATCH -next] pinctrl: mediatek: moore: fix return value check in mtk_moore_pinctrl_probe() Wei Yongjun
@ 2018-09-21  2:01 ` Sean Wang
       [not found] ` <1537424510-23623-1-git-send-email-weiyongjun1-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
  2018-09-21 16:08 ` Linus Walleij
  2 siblings, 0 replies; 4+ messages in thread
From: Sean Wang @ 2018-09-21  2:01 UTC (permalink / raw)
  To: Wei Yongjun
  Cc: Ryder.Lee, Linus Walleij, kernel-janitors, linux-gpio,
	linux-mediatek, Matthias Brugger, linux-arm-kernel

On Thu, 2018-09-20 at 06:21 +0000, Wei Yongjun wrote:
> In case of error, the function devm_kmalloc_array() returns NULL pointer
> not ERR_PTR(). The IS_ERR() test in the return value check should be
> replaced with NULL test.
> 
> Fixes: b7d7f9eeca55 ("pinctrl: mediatek: extend struct mtk_pin_desc which per-pin driver depends on")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

Acked-by: Sean Wang <sean.wang@mediatek.com>

> ---
>  drivers/pinctrl/mediatek/pinctrl-moore.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pinctrl/mediatek/pinctrl-moore.c b/drivers/pinctrl/mediatek/pinctrl-moore.c
> index c27597c..3bf5dd5 100644
> --- a/drivers/pinctrl/mediatek/pinctrl-moore.c
> +++ b/drivers/pinctrl/mediatek/pinctrl-moore.c
> @@ -608,8 +608,8 @@ int mtk_moore_pinctrl_probe(struct platform_device *pdev,
>  
>  	hw->base = devm_kmalloc_array(&pdev->dev, hw->soc->nbase_names,
>  				      sizeof(*hw->base), GFP_KERNEL);
> -	if (IS_ERR(hw->base))
> -		return PTR_ERR(hw->base);
> +	if (!hw->base)
> +		return -ENOMEM;
>  
>  	for (i = 0; i < hw->soc->nbase_names; i++) {
>  		res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
> @@ -629,8 +629,8 @@ int mtk_moore_pinctrl_probe(struct platform_device *pdev,
>  	/* Copy from internal struct mtk_pin_desc to register to the core */
>  	pins = devm_kmalloc_array(&pdev->dev, hw->soc->npins, sizeof(*pins),
>  				  GFP_KERNEL);
> -	if (IS_ERR(pins))
> -		return PTR_ERR(pins);
> +	if (!pins)
> +		return -ENOMEM;
>  
>  	for (i = 0; i < hw->soc->npins; i++) {
>  		pins[i].number = hw->soc->pins[i].number;
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -next] pinctrl: mediatek: moore: fix return value check in mtk_moore_pinctrl_probe()
       [not found] ` <1537424510-23623-1-git-send-email-weiyongjun1-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
@ 2018-09-21  2:18   ` Sean Wang
  0 siblings, 0 replies; 4+ messages in thread
From: Sean Wang @ 2018-09-21  2:18 UTC (permalink / raw)
  To: Wei Yongjun
  Cc: Ryder.Lee, Linus Walleij, kernel-janitors-u79uwXL29TY76Z2rM5mHXA,
	linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Matthias Brugger,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On Thu, 2018-09-20 at 06:21 +0000, Wei Yongjun wrote:
> In case of error, the function devm_kmalloc_array() returns NULL pointer
> not ERR_PTR(). The IS_ERR() test in the return value check should be
> replaced with NULL test.
> 
> Fixes: b7d7f9eeca55 ("pinctrl: mediatek: extend struct mtk_pin_desc which per-pin driver depends on")
> Signed-off-by: Wei Yongjun <weiyongjun1-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>

Acked-by: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>

> ---
>  drivers/pinctrl/mediatek/pinctrl-moore.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pinctrl/mediatek/pinctrl-moore.c b/drivers/pinctrl/mediatek/pinctrl-moore.c
> index c27597c..3bf5dd5 100644
> --- a/drivers/pinctrl/mediatek/pinctrl-moore.c
> +++ b/drivers/pinctrl/mediatek/pinctrl-moore.c
> @@ -608,8 +608,8 @@ int mtk_moore_pinctrl_probe(struct platform_device *pdev,
>  
>  	hw->base = devm_kmalloc_array(&pdev->dev, hw->soc->nbase_names,
>  				      sizeof(*hw->base), GFP_KERNEL);
> -	if (IS_ERR(hw->base))
> -		return PTR_ERR(hw->base);
> +	if (!hw->base)
> +		return -ENOMEM;
>  
>  	for (i = 0; i < hw->soc->nbase_names; i++) {
>  		res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
> @@ -629,8 +629,8 @@ int mtk_moore_pinctrl_probe(struct platform_device *pdev,
>  	/* Copy from internal struct mtk_pin_desc to register to the core */
>  	pins = devm_kmalloc_array(&pdev->dev, hw->soc->npins, sizeof(*pins),
>  				  GFP_KERNEL);
> -	if (IS_ERR(pins))
> -		return PTR_ERR(pins);
> +	if (!pins)
> +		return -ENOMEM;
>  
>  	for (i = 0; i < hw->soc->npins; i++) {
>  		pins[i].number = hw->soc->pins[i].number;
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -next] pinctrl: mediatek: moore: fix return value check in mtk_moore_pinctrl_probe()
  2018-09-20  6:21 [PATCH -next] pinctrl: mediatek: moore: fix return value check in mtk_moore_pinctrl_probe() Wei Yongjun
  2018-09-21  2:01 ` Sean Wang
       [not found] ` <1537424510-23623-1-git-send-email-weiyongjun1-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
@ 2018-09-21 16:08 ` Linus Walleij
  2 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2018-09-21 16:08 UTC (permalink / raw)
  To: Wei Yongjun
  Cc: Ryder Lee, Sean Wang, kernel-janitors, open list:GPIO SUBSYSTEM,
	moderated list:ARM/Mediatek SoC support, Matthias Brugger,
	Linux ARM

On Wed, Sep 19, 2018 at 11:12 PM Wei Yongjun <weiyongjun1@huawei.com> wrote:

> In case of error, the function devm_kmalloc_array() returns NULL pointer
> not ERR_PTR(). The IS_ERR() test in the return value check should be
> replaced with NULL test.
>
> Fixes: b7d7f9eeca55 ("pinctrl: mediatek: extend struct mtk_pin_desc which per-pin driver depends on")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

Patch applied with Sean's ACK.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-09-21 16:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-20  6:21 [PATCH -next] pinctrl: mediatek: moore: fix return value check in mtk_moore_pinctrl_probe() Wei Yongjun
2018-09-21  2:01 ` Sean Wang
     [not found] ` <1537424510-23623-1-git-send-email-weiyongjun1-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2018-09-21  2:18   ` Sean Wang
2018-09-21 16:08 ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).