public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/fb-helper: Do the mode_set.connectors ZERO_SIZE_PTR check
@ 2014-03-06  6:34 Xiubo Li
  2014-03-07  8:28 ` Jani Nikula
  0 siblings, 1 reply; 3+ messages in thread
From: Xiubo Li @ 2014-03-06  6:34 UTC (permalink / raw)
  To: airlied, dri-devel; +Cc: linux-kernel, Xiubo Li

Since we cannot make sure the 'max_conn_count' will always be none
zero from the users, and then if max_conn_count equals to zero, the
kcalloc() will return ZERO_SIZE_PTR, which equals to ((void *)16).

So this patch fix this via doing the zero pionter check of it.

Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
---
 drivers/gpu/drm/drm_fb_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 3d13ca6e2..c6680ef 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -536,7 +536,7 @@ int drm_fb_helper_init(struct drm_device *dev,
 				sizeof(struct drm_connector *),
 				GFP_KERNEL);
 
-		if (!fb_helper->crtc_info[i].mode_set.connectors)
+		if (ZERO_OR_NULL_PTR(fb_helper->crtc_info[i].mode_set.connectors))
 			goto out_free;
 		fb_helper->crtc_info[i].mode_set.num_connectors = 0;
 	}
-- 
1.8.4



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

* Re: [PATCH] drm/fb-helper: Do the mode_set.connectors ZERO_SIZE_PTR check
  2014-03-06  6:34 [PATCH] drm/fb-helper: Do the mode_set.connectors ZERO_SIZE_PTR check Xiubo Li
@ 2014-03-07  8:28 ` Jani Nikula
  2014-03-10  2:11   ` Li.Xiubo
  0 siblings, 1 reply; 3+ messages in thread
From: Jani Nikula @ 2014-03-07  8:28 UTC (permalink / raw)
  To: Xiubo Li, airlied, dri-devel; +Cc: Xiubo Li, linux-kernel

On Thu, 06 Mar 2014, Xiubo Li <Li.Xiubo@freescale.com> wrote:
> Since we cannot make sure the 'max_conn_count' will always be none
> zero from the users, and then if max_conn_count equals to zero, the
> kcalloc() will return ZERO_SIZE_PTR, which equals to ((void *)16).
>
> So this patch fix this via doing the zero pionter check of it.

Please just add a check for max_conn_count == 0 up front and handle it.

BR,
Jani.


>
> Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
> ---
>  drivers/gpu/drm/drm_fb_helper.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index 3d13ca6e2..c6680ef 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -536,7 +536,7 @@ int drm_fb_helper_init(struct drm_device *dev,
>  				sizeof(struct drm_connector *),
>  				GFP_KERNEL);
>  
> -		if (!fb_helper->crtc_info[i].mode_set.connectors)
> +		if (ZERO_OR_NULL_PTR(fb_helper->crtc_info[i].mode_set.connectors))
>  			goto out_free;
>  		fb_helper->crtc_info[i].mode_set.num_connectors = 0;
>  	}
> -- 
> 1.8.4
>
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Jani Nikula, Intel Open Source Technology Center

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

* RE: [PATCH] drm/fb-helper: Do the mode_set.connectors ZERO_SIZE_PTR check
  2014-03-07  8:28 ` Jani Nikula
@ 2014-03-10  2:11   ` Li.Xiubo
  0 siblings, 0 replies; 3+ messages in thread
From: Li.Xiubo @ 2014-03-10  2:11 UTC (permalink / raw)
  To: Jani Nikula, airlied@linux.ie, dri-devel@lists.freedesktop.org
  Cc: linux-kernel@vger.kernel.org


> Subject: Re: [PATCH] drm/fb-helper: Do the mode_set.connectors ZERO_SIZE_PTR
> check
> 
> On Thu, 06 Mar 2014, Xiubo Li <Li.Xiubo@freescale.com> wrote:
> > Since we cannot make sure the 'max_conn_count' will always be none
> > zero from the users, and then if max_conn_count equals to zero, the
> > kcalloc() will return ZERO_SIZE_PTR, which equals to ((void *)16).
> >
> > So this patch fix this via doing the zero pionter check of it.
> 
> Please just add a check for max_conn_count == 0 up front and handle it.
> 
> BR,
> Jani.
> 

Yes, that's one better choice.
See the next version please.

Thanks very much!

--
Best Regards,
Xiubo 

> 
> >
> > Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
> > ---
> >  drivers/gpu/drm/drm_fb_helper.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/drm_fb_helper.c
> b/drivers/gpu/drm/drm_fb_helper.c
> > index 3d13ca6e2..c6680ef 100644
> > --- a/drivers/gpu/drm/drm_fb_helper.c
> > +++ b/drivers/gpu/drm/drm_fb_helper.c
> > @@ -536,7 +536,7 @@ int drm_fb_helper_init(struct drm_device *dev,
> >  				sizeof(struct drm_connector *),
> >  				GFP_KERNEL);
> >
> > -		if (!fb_helper->crtc_info[i].mode_set.connectors)
> > +		if (ZERO_OR_NULL_PTR(fb_helper->crtc_info[i].mode_set.connectors))
> >  			goto out_free;
> >  		fb_helper->crtc_info[i].mode_set.num_connectors = 0;
> >  	}
> > --
> > 1.8.4
> >
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
> --
> Jani Nikula, Intel Open Source Technology Center
> 


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

end of thread, other threads:[~2014-03-10  2:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-06  6:34 [PATCH] drm/fb-helper: Do the mode_set.connectors ZERO_SIZE_PTR check Xiubo Li
2014-03-07  8:28 ` Jani Nikula
2014-03-10  2:11   ` Li.Xiubo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox