diff mbox

drm/rockchip: return ERR_PTR instead of NULL

Message ID 1478812256-26189-1-git-send-email-Julia.Lawall@lip6.fr (mailing list archive)
State New, archived
Headers show

Commit Message

Julia Lawall Nov. 10, 2016, 9:10 p.m. UTC
rockchip_drm_framebuffer_init is only used in one case, in
rockchip_drm_fbdev.c, where its return value is tested using IS_ERR.  To
enable propagating the reason for the error, change the definition so that
it returns an ERR_PTR value.

Problem found with the help of Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/gpu/drm/rockchip/rockchip_drm_fb.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

yao mark Nov. 11, 2016, 1:45 a.m. UTC | #1
On 2016年11月11日 05:10, Julia Lawall wrote:
> rockchip_drm_framebuffer_init is only used in one case, in
> rockchip_drm_fbdev.c, where its return value is tested using IS_ERR.  To
> enable propagating the reason for the error, change the definition so that
> it returns an ERR_PTR value.
>
> Problem found with the help of Coccinelle.
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Thanks for the fix.

Applied to my drm-next.

>
> ---
>   drivers/gpu/drm/rockchip/rockchip_drm_fb.c |    2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
> index 0f6eda0..01e11bf 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
> @@ -213,7 +213,7 @@ struct drm_framebuffer *
>   
>   	rockchip_fb = rockchip_fb_alloc(dev, mode_cmd, &obj, 1);
>   	if (IS_ERR(rockchip_fb))
> -		return NULL;
> +		return ERR_CAST(rockchip_fb);
>   
>   	return &rockchip_fb->fb;
>   }
>
>
>
>
Walter Harms Nov. 11, 2016, 8:13 a.m. UTC | #2
Am 11.11.2016 02:45, schrieb Mark yao:
> On 2016年11月11日 05:10, Julia Lawall wrote:
>> rockchip_drm_framebuffer_init is only used in one case, in
>> rockchip_drm_fbdev.c, where its return value is tested using IS_ERR.  To
>> enable propagating the reason for the error, change the definition so
>> that
>> it returns an ERR_PTR value.
>>
>> Problem found with the help of Coccinelle.
>>
>> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> Thanks for the fix.
> 
> Applied to my drm-next.

Just for my curiosity.

can more go wrong that OOM ?

i did not see that.

re,
 wh


> 
>>
>> ---
>>   drivers/gpu/drm/rockchip/rockchip_drm_fb.c |    2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
>> b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
>> index 0f6eda0..01e11bf 100644
>> --- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
>> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
>> @@ -213,7 +213,7 @@ struct drm_framebuffer *
>>         rockchip_fb = rockchip_fb_alloc(dev, mode_cmd, &obj, 1);
>>       if (IS_ERR(rockchip_fb))
>> -        return NULL;
>> +        return ERR_CAST(rockchip_fb);
>>         return &rockchip_fb->fb;
>>   }
>>
>>
>>
>>
> 
>
Julia Lawall Nov. 11, 2016, 8:22 a.m. UTC | #3
On Fri, 11 Nov 2016, walter harms wrote:

>
>
> Am 11.11.2016 02:45, schrieb Mark yao:
> > On 2016年11月11日 05:10, Julia Lawall wrote:
> >> rockchip_drm_framebuffer_init is only used in one case, in
> >> rockchip_drm_fbdev.c, where its return value is tested using IS_ERR.  To
> >> enable propagating the reason for the error, change the definition so
> >> that
> >> it returns an ERR_PTR value.
> >>
> >> Problem found with the help of Coccinelle.
> >>
> >> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> > Thanks for the fix.
> >
> > Applied to my drm-next.
>
> Just for my curiosity.
>
> can more go wrong that OOM ?

Unfolding rockchip_fb_alloc suggests that a variety of error codes can be
returned, notably from the function idr_alloc.

julia

>
> i did not see that.
>
> re,
>  wh
>
>
> >
> >>
> >> ---
> >>   drivers/gpu/drm/rockchip/rockchip_drm_fb.c |    2 +-
> >>   1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
> >> b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
> >> index 0f6eda0..01e11bf 100644
> >> --- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
> >> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
> >> @@ -213,7 +213,7 @@ struct drm_framebuffer *
> >>         rockchip_fb = rockchip_fb_alloc(dev, mode_cmd, &obj, 1);
> >>       if (IS_ERR(rockchip_fb))
> >> -        return NULL;
> >> +        return ERR_CAST(rockchip_fb);
> >>         return &rockchip_fb->fb;
> >>   }
> >>
> >>
> >>
> >>
> >
> >
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
index 0f6eda0..01e11bf 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
@@ -213,7 +213,7 @@  struct drm_framebuffer *
 
 	rockchip_fb = rockchip_fb_alloc(dev, mode_cmd, &obj, 1);
 	if (IS_ERR(rockchip_fb))
-		return NULL;
+		return ERR_CAST(rockchip_fb);
 
 	return &rockchip_fb->fb;
 }