2013-10-25 09:07:22

by Wei Yongjun

[permalink] [raw]
Subject: [PATCH] staging: drm/imx: fix return value check in imx_drm_init()

From: Wei Yongjun <[email protected]>

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

Signed-off-by: Wei Yongjun <[email protected]>
---
drivers/staging/imx-drm/imx-drm-core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c
index a2e52a0..835a1b1 100644
--- a/drivers/staging/imx-drm/imx-drm-core.c
+++ b/drivers/staging/imx-drm/imx-drm-core.c
@@ -837,8 +837,8 @@ static int __init imx_drm_init(void)
INIT_LIST_HEAD(&imx_drm_device->encoder_list);

imx_drm_pdev = platform_device_register_simple("imx-drm", -1, NULL, 0);
- if (!imx_drm_pdev) {
- ret = -EINVAL;
+ if (IS_ERR(imx_drm_pdev)) {
+ ret = PTR_ERR(imx_drm_pdev);
goto err_pdev;
}


2013-10-28 07:57:47

by Sascha Hauer

[permalink] [raw]
Subject: Re: [PATCH] staging: drm/imx: fix return value check in imx_drm_init()

On Fri, Oct 25, 2013 at 05:07:18PM +0800, Wei Yongjun wrote:
> From: Wei Yongjun <[email protected]>
>
> In case of error, the function platform_device_register_simple() returns
> ERR_PTR() and never returns NULL. The NULL test in the return value check
> should be replaced with IS_ERR().
>
> Signed-off-by: Wei Yongjun <[email protected]>

Acked-by: Sascha Hauer <[email protected]>

Sascha

> ---
> drivers/staging/imx-drm/imx-drm-core.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c
> index a2e52a0..835a1b1 100644
> --- a/drivers/staging/imx-drm/imx-drm-core.c
> +++ b/drivers/staging/imx-drm/imx-drm-core.c
> @@ -837,8 +837,8 @@ static int __init imx_drm_init(void)
> INIT_LIST_HEAD(&imx_drm_device->encoder_list);
>
> imx_drm_pdev = platform_device_register_simple("imx-drm", -1, NULL, 0);
> - if (!imx_drm_pdev) {
> - ret = -EINVAL;
> + if (IS_ERR(imx_drm_pdev)) {
> + ret = PTR_ERR(imx_drm_pdev);
> goto err_pdev;
> }
>
>
>

--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |