[media] vimc: Fix return value check in vimc_add_subdevs()
diff mbox

Message ID 1507720603-128932-1-git-send-email-weiyongjun1@huawei.com
State New
Headers show

Commit Message

Wei Yongjun Oct. 11, 2017, 11:16 a.m. UTC
In case of error, the function platform_device_register_data() 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 <weiyongjun1@huawei.com>
---
 drivers/media/platform/vimc/vimc-core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Helen Koike Oct. 11, 2017, 1:25 p.m. UTC | #1
Hello,


On 2017-10-11 08:16 AM, Wei Yongjun wrote:
> In case of error, the function platform_device_register_data() 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 <weiyongjun1@huawei.com>
> ---
>  drivers/media/platform/vimc/vimc-core.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/vimc/vimc-core.c b/drivers/media/platform/vimc/vimc-core.c
> index 51c0eee..fe088a9 100644
> --- a/drivers/media/platform/vimc/vimc-core.c
> +++ b/drivers/media/platform/vimc/vimc-core.c
> @@ -267,11 +267,12 @@ static struct component_match *vimc_add_subdevs(struct vimc_device *vimc)
>  						PLATFORM_DEVID_AUTO,
>  						&pdata,
>  						sizeof(pdata));
> -		if (!vimc->subdevs[i]) {
> +		if (IS_ERR(vimc->subdevs[i])) {
> +			match = ERR_CAST(vimc->subdevs[i]);
>  			while (--i >= 0)
>  				platform_device_unregister(vimc->subdevs[i]);
>  
> -			return ERR_PTR(-ENOMEM);
> +			return match;
>  		}
>  
>  		component_match_add(&vimc->pdev.dev, &match, vimc_comp_compare,
> 
> 
> 

Nice catch, thanks, looks good to me

Acked-by: Helen Koike <helen.koike@collabora.com>

Patch
diff mbox

diff --git a/drivers/media/platform/vimc/vimc-core.c b/drivers/media/platform/vimc/vimc-core.c
index 51c0eee..fe088a9 100644
--- a/drivers/media/platform/vimc/vimc-core.c
+++ b/drivers/media/platform/vimc/vimc-core.c
@@ -267,11 +267,12 @@  static struct component_match *vimc_add_subdevs(struct vimc_device *vimc)
 						PLATFORM_DEVID_AUTO,
 						&pdata,
 						sizeof(pdata));
-		if (!vimc->subdevs[i]) {
+		if (IS_ERR(vimc->subdevs[i])) {
+			match = ERR_CAST(vimc->subdevs[i]);
 			while (--i >= 0)
 				platform_device_unregister(vimc->subdevs[i]);
 
-			return ERR_PTR(-ENOMEM);
+			return match;
 		}
 
 		component_match_add(&vimc->pdev.dev, &match, vimc_comp_compare,