diff mbox

drm/xen-front: Fix error code in xen_drm_front_gem_get_sg_table()

Message ID 20180719081133.k7asay4fl2qhhpjf@mwanda (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Carpenter July 19, 2018, 8:11 a.m. UTC
The xen_drm_front_gem_get_sg_table() function is supposed to return
error pointer.  The current code, would trigger a NULL dereference in
drm_gem_map_dma_buf().

Fixes: c575b7eeb89f ("drm/xen-front: Add support for Xen PV display frontend")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Comments

Oleksandr Andrushchenko July 19, 2018, 9:06 a.m. UTC | #1
Hi, Dan!

Thank you for the patch and sorry I was clumsy sending v3.

Do you want me to send v3 now with the fixes for both Xen and CMA?

Thank you,

Oleksandr


On 07/19/2018 11:11 AM, Dan Carpenter wrote:
> The xen_drm_front_gem_get_sg_table() function is supposed to return
> error pointer.  The current code, would trigger a NULL dereference in
> drm_gem_map_dma_buf().
>
> Fixes: c575b7eeb89f ("drm/xen-front: Add support for Xen PV display frontend")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/gpu/drm/xen/xen_drm_front_gem.c b/drivers/gpu/drm/xen/xen_drm_front_gem.c
> index c85bfe7571cb..4507bc03ed8f 100644
> --- a/drivers/gpu/drm/xen/xen_drm_front_gem.c
> +++ b/drivers/gpu/drm/xen/xen_drm_front_gem.c
> @@ -179,7 +179,7 @@ struct sg_table *xen_drm_front_gem_get_sg_table(struct drm_gem_object *gem_obj)
>   	struct xen_gem_object *xen_obj = to_xen_gem_obj(gem_obj);
>   
>   	if (!xen_obj->pages)
> -		return NULL;
> +		return ERR_PTR(-EINVAL);
>   
>   	return drm_prime_pages_to_sg(xen_obj->pages, xen_obj->num_pages);
>   }
Dan Carpenter July 19, 2018, 9:20 a.m. UTC | #2
On Thu, Jul 19, 2018 at 12:06:38PM +0300, Oleksandr Andrushchenko wrote:
> Hi, Dan!
> 
> Thank you for the patch and sorry I was clumsy sending v3.
> 
> Do you want me to send v3 now with the fixes for both Xen and CMA?
> 
> Thank you,

Sorry, I forgot that you had sent these earlier.  After a while these
things all look the same.  I once accidentally wrote and sent the same
patch three times without realizing.

Yeah.  Please resend a v3.

regards,
dan carpenter
Dan Carpenter July 19, 2018, 9:20 a.m. UTC | #3
Oleksandr sent this patch already.  Please disregard mine.

regards,
dan carpenter
Oleksandr Andrushchenko July 19, 2018, 9:25 a.m. UTC | #4
On 07/19/2018 12:20 PM, Dan Carpenter wrote:
> On Thu, Jul 19, 2018 at 12:06:38PM +0300, Oleksandr Andrushchenko wrote:
>> Hi, Dan!
>>
>> Thank you for the patch and sorry I was clumsy sending v3.
>>
>> Do you want me to send v3 now with the fixes for both Xen and CMA?
>>
>> Thank you,
> Sorry, I forgot that you had sent these earlier.  After a while these
> things all look the same.  I once accidentally wrote and sent the same
> patch three times without realizing.
np
> Yeah.  Please resend a v3.
sure
> regards,
> dan carpenter
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/xen/xen_drm_front_gem.c b/drivers/gpu/drm/xen/xen_drm_front_gem.c
index c85bfe7571cb..4507bc03ed8f 100644
--- a/drivers/gpu/drm/xen/xen_drm_front_gem.c
+++ b/drivers/gpu/drm/xen/xen_drm_front_gem.c
@@ -179,7 +179,7 @@  struct sg_table *xen_drm_front_gem_get_sg_table(struct drm_gem_object *gem_obj)
 	struct xen_gem_object *xen_obj = to_xen_gem_obj(gem_obj);
 
 	if (!xen_obj->pages)
-		return NULL;
+		return ERR_PTR(-EINVAL);
 
 	return drm_prime_pages_to_sg(xen_obj->pages, xen_obj->num_pages);
 }