linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/vmwgfx: use kzalloc in vmw_surface_define_ioctl()
@ 2015-09-30 19:53 Rasmus Villemoes
  2015-09-30 19:53 ` [PATCH 2/2] drm/omap: use kzalloc in sita_init() Rasmus Villemoes
  2015-09-30 20:54 ` [PATCH 1/2] drm/vmwgfx: use kzalloc in vmw_surface_define_ioctl() kbuild test robot
  0 siblings, 2 replies; 4+ messages in thread
From: Rasmus Villemoes @ 2015-09-30 19:53 UTC (permalink / raw)
  To: David Airlie; +Cc: Rasmus Villemoes, dri-devel, linux-kernel

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
index 64b50409fa07..38d910ae9b21 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
@@ -814,11 +814,8 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data,
 	    srf->sizes[0].height == 64 &&
 	    srf->format == SVGA3D_A8R8G8B8) {
 
-		srf->snooper.image = kmalloc(64 * 64 * 4, GFP_KERNEL);
-		/* clear the image */
-		if (srf->snooper.image) {
-			memset(srf->snooper.image, 0x00, 64 * 64 * 4);
-		} else {
+		srf->snooper.image = kzalloc(64 * 64 * 4, GFP_KERNEL);
+		if (!srf->snooper.image) {
 			DRM_ERROR("Failed to allocate cursor_image\n");
 			ret = -ENOMEM;
 			goto out_no_copy;
-- 
2.1.3


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

* [PATCH 2/2] drm/omap: use kzalloc in sita_init()
  2015-09-30 19:53 [PATCH 1/2] drm/vmwgfx: use kzalloc in vmw_surface_define_ioctl() Rasmus Villemoes
@ 2015-09-30 19:53 ` Rasmus Villemoes
  2015-09-30 20:54 ` [PATCH 1/2] drm/vmwgfx: use kzalloc in vmw_surface_define_ioctl() kbuild test robot
  1 sibling, 0 replies; 4+ messages in thread
From: Rasmus Villemoes @ 2015-09-30 19:53 UTC (permalink / raw)
  To: David Airlie; +Cc: Rasmus Villemoes, dri-devel, linux-kernel

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 drivers/gpu/drm/omapdrm/tcm-sita.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/tcm-sita.c b/drivers/gpu/drm/omapdrm/tcm-sita.c
index efb609510540..6df1f2a1bc52 100644
--- a/drivers/gpu/drm/omapdrm/tcm-sita.c
+++ b/drivers/gpu/drm/omapdrm/tcm-sita.c
@@ -87,14 +87,11 @@ struct tcm *sita_init(u16 width, u16 height, struct tcm_pt *attr)
 	if (width == 0 || height == 0)
 		return NULL;
 
-	tcm = kmalloc(sizeof(*tcm), GFP_KERNEL);
-	pvt = kmalloc(sizeof(*pvt), GFP_KERNEL);
+	tcm = kzalloc(sizeof(*tcm), GFP_KERNEL);
+	pvt = kzalloc(sizeof(*pvt), GFP_KERNEL);
 	if (!tcm || !pvt)
 		goto error;
 
-	memset(tcm, 0, sizeof(*tcm));
-	memset(pvt, 0, sizeof(*pvt));
-
 	/* Updating the pointers to SiTA implementation APIs */
 	tcm->height = height;
 	tcm->width = width;
-- 
2.1.3


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

* Re: [PATCH 1/2] drm/vmwgfx: use kzalloc in vmw_surface_define_ioctl()
  2015-09-30 19:53 [PATCH 1/2] drm/vmwgfx: use kzalloc in vmw_surface_define_ioctl() Rasmus Villemoes
  2015-09-30 19:53 ` [PATCH 2/2] drm/omap: use kzalloc in sita_init() Rasmus Villemoes
@ 2015-09-30 20:54 ` kbuild test robot
  2015-09-30 21:08   ` Rasmus Villemoes
  1 sibling, 1 reply; 4+ messages in thread
From: kbuild test robot @ 2015-09-30 20:54 UTC (permalink / raw)
  To: Rasmus Villemoes
  Cc: kbuild-all, David Airlie, Rasmus Villemoes, dri-devel,
	linux-kernel

Hi Rasmus,

[auto build test results on v4.3-rc3 -- if it's inappropriate base, please ignore]


coccinelle warnings: (new ones prefixed by >>)

>> drivers/gpu/drm/vmwgfx/vmwgfx_surface.c:771:1-13: alloc with no test, possible model on line 817

vim +771 drivers/gpu/drm/vmwgfx/vmwgfx_surface.c

543831cf Thomas Hellstrom 2012-11-20  765  
543831cf Thomas Hellstrom 2012-11-20  766  	srf->sizes = kmalloc(srf->num_sizes * sizeof(*srf->sizes), GFP_KERNEL);
543831cf Thomas Hellstrom 2012-11-20  767  	if (unlikely(srf->sizes == NULL)) {
543831cf Thomas Hellstrom 2012-11-20  768  		ret = -ENOMEM;
543831cf Thomas Hellstrom 2012-11-20  769  		goto out_no_sizes;
543831cf Thomas Hellstrom 2012-11-20  770  	}
543831cf Thomas Hellstrom 2012-11-20 @771  	srf->offsets = kmalloc(srf->num_sizes * sizeof(*srf->offsets),
543831cf Thomas Hellstrom 2012-11-20  772  			       GFP_KERNEL);
543831cf Thomas Hellstrom 2012-11-20  773  	if (unlikely(srf->sizes == NULL)) {
543831cf Thomas Hellstrom 2012-11-20  774  		ret = -ENOMEM;
543831cf Thomas Hellstrom 2012-11-20  775  		goto out_no_offsets;
543831cf Thomas Hellstrom 2012-11-20  776  	}
543831cf Thomas Hellstrom 2012-11-20  777  
543831cf Thomas Hellstrom 2012-11-20  778  	user_sizes = (struct drm_vmw_size __user *)(unsigned long)
543831cf Thomas Hellstrom 2012-11-20  779  	    req->size_addr;
543831cf Thomas Hellstrom 2012-11-20  780  
543831cf Thomas Hellstrom 2012-11-20  781  	ret = copy_from_user(srf->sizes, user_sizes,
543831cf Thomas Hellstrom 2012-11-20  782  			     srf->num_sizes * sizeof(*srf->sizes));
543831cf Thomas Hellstrom 2012-11-20  783  	if (unlikely(ret != 0)) {
543831cf Thomas Hellstrom 2012-11-20  784  		ret = -EFAULT;
543831cf Thomas Hellstrom 2012-11-20  785  		goto out_no_copy;
543831cf Thomas Hellstrom 2012-11-20  786  	}
543831cf Thomas Hellstrom 2012-11-20  787  
543831cf Thomas Hellstrom 2012-11-20  788  	srf->base_size = *srf->sizes;
543831cf Thomas Hellstrom 2012-11-20  789  	srf->autogen_filter = SVGA3D_TEX_FILTER_NONE;
15c6f656 Zack Rusin       2012-11-21  790  	srf->multisample_count = 0;
543831cf Thomas Hellstrom 2012-11-20  791  
543831cf Thomas Hellstrom 2012-11-20  792  	cur_bo_offset = 0;
543831cf Thomas Hellstrom 2012-11-20  793  	cur_offset = srf->offsets;
543831cf Thomas Hellstrom 2012-11-20  794  	cur_size = srf->sizes;
543831cf Thomas Hellstrom 2012-11-20  795  
543831cf Thomas Hellstrom 2012-11-20  796  	for (i = 0; i < DRM_VMW_MAX_SURFACE_FACES; ++i) {
543831cf Thomas Hellstrom 2012-11-20  797  		for (j = 0; j < srf->mip_levels[i]; ++j) {
7e8d9da3 Thomas Hellstrom 2012-11-20  798  			uint32_t stride = svga3dsurface_calculate_pitch
7e8d9da3 Thomas Hellstrom 2012-11-20  799  				(desc, cur_size);
543831cf Thomas Hellstrom 2012-11-20  800  
543831cf Thomas Hellstrom 2012-11-20  801  			cur_offset->face = i;
543831cf Thomas Hellstrom 2012-11-20  802  			cur_offset->mip = j;
543831cf Thomas Hellstrom 2012-11-20  803  			cur_offset->bo_offset = cur_bo_offset;
7e8d9da3 Thomas Hellstrom 2012-11-20  804  			cur_bo_offset += svga3dsurface_get_image_buffer_size
7e8d9da3 Thomas Hellstrom 2012-11-20  805  				(desc, cur_size, stride);
543831cf Thomas Hellstrom 2012-11-20  806  			++cur_offset;
543831cf Thomas Hellstrom 2012-11-20  807  			++cur_size;
543831cf Thomas Hellstrom 2012-11-20  808  		}
543831cf Thomas Hellstrom 2012-11-20  809  	}
543831cf Thomas Hellstrom 2012-11-20  810  	res->backup_size = cur_bo_offset;
543831cf Thomas Hellstrom 2012-11-20  811  	if (srf->scanout &&
543831cf Thomas Hellstrom 2012-11-20  812  	    srf->num_sizes == 1 &&
543831cf Thomas Hellstrom 2012-11-20  813  	    srf->sizes[0].width == 64 &&
543831cf Thomas Hellstrom 2012-11-20  814  	    srf->sizes[0].height == 64 &&
543831cf Thomas Hellstrom 2012-11-20  815  	    srf->format == SVGA3D_A8R8G8B8) {
543831cf Thomas Hellstrom 2012-11-20  816  
fc815f88 Rasmus Villemoes 2015-09-30 @817  		srf->snooper.image = kzalloc(64 * 64 * 4, GFP_KERNEL);
fc815f88 Rasmus Villemoes 2015-09-30  818  		if (!srf->snooper.image) {
543831cf Thomas Hellstrom 2012-11-20  819  			DRM_ERROR("Failed to allocate cursor_image\n");
543831cf Thomas Hellstrom 2012-11-20  820  			ret = -ENOMEM;

:::::: The code at line 771 was first introduced by commit
:::::: 543831cfc976669b8da963b3e94933e21e051846 drm/vmwgfx: Break out surface and context management to separate files

:::::: TO: Thomas Hellstrom <thellstrom@vmware.com>
:::::: CC: Dave Airlie <airlied@redhat.com>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

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

* Re: [PATCH 1/2] drm/vmwgfx: use kzalloc in vmw_surface_define_ioctl()
  2015-09-30 20:54 ` [PATCH 1/2] drm/vmwgfx: use kzalloc in vmw_surface_define_ioctl() kbuild test robot
@ 2015-09-30 21:08   ` Rasmus Villemoes
  0 siblings, 0 replies; 4+ messages in thread
From: Rasmus Villemoes @ 2015-09-30 21:08 UTC (permalink / raw)
  To: kbuild test robot; +Cc: kbuild-all, David Airlie, dri-devel, linux-kernel

On Wed, Sep 30 2015, kbuild test robot <lkp@intel.com> wrote:

> Hi Rasmus,
>
> [auto build test results on v4.3-rc3 -- if it's inappropriate base, please ignore]
>
>
> coccinelle warnings: (new ones prefixed by >>)
>
>>> drivers/gpu/drm/vmwgfx/vmwgfx_surface.c:771:1-13: alloc with no test, possible model on line 817
>
> vim +771 drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
>
> 543831cf Thomas Hellstrom 2012-11-20  765  
> 543831cf Thomas Hellstrom 2012-11-20  766  	srf->sizes = kmalloc(srf->num_sizes * sizeof(*srf->sizes), GFP_KERNEL);
> 543831cf Thomas Hellstrom 2012-11-20  767  	if (unlikely(srf->sizes == NULL)) {
> 543831cf Thomas Hellstrom 2012-11-20  768  		ret = -ENOMEM;
> 543831cf Thomas Hellstrom 2012-11-20  769  		goto out_no_sizes;
> 543831cf Thomas Hellstrom 2012-11-20  770  	}
> 543831cf Thomas Hellstrom 2012-11-20 @771  	srf->offsets = kmalloc(srf->num_sizes * sizeof(*srf->offsets),
> 543831cf Thomas Hellstrom 2012-11-20  772  			       GFP_KERNEL);
> 543831cf Thomas Hellstrom 2012-11-20  773  	if (unlikely(srf->sizes == NULL)) {
> 543831cf Thomas Hellstrom 2012-11-20  774  		ret = -ENOMEM;
> 543831cf Thomas Hellstrom 2012-11-20  775  		goto out_no_offsets;
> 543831cf Thomas Hellstrom 2012-11-20  776  	}
> 543831cf Thomas Hellstrom 2012-11-20  777  

Wauv, that was fast. So, I'm pretty sure this has nothing to do with the
patch I just sent, but there's a bug nevertheless. The NULL test has
been copy-pasted from just above, but we're testing srf->sizes again,
not srf->offsets which we just tried to allocate.

Subject: [PATCH] drm/vmwgfx: check kmalloc return value

srf->sizes has been allocated and checked a few lines above; fix up
the copy-pasto so that we check srf->offsets.

Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
index 64b50409fa07..0cf0055e0e08 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
@@ -770,7 +770,7 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data,
 	}
 	srf->offsets = kmalloc(srf->num_sizes * sizeof(*srf->offsets),
 			       GFP_KERNEL);
-	if (unlikely(srf->sizes == NULL)) {
+	if (unlikely(srf->offsets == NULL)) {
 		ret = -ENOMEM;
 		goto out_no_offsets;
 	}


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

end of thread, other threads:[~2015-09-30 21:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-30 19:53 [PATCH 1/2] drm/vmwgfx: use kzalloc in vmw_surface_define_ioctl() Rasmus Villemoes
2015-09-30 19:53 ` [PATCH 2/2] drm/omap: use kzalloc in sita_init() Rasmus Villemoes
2015-09-30 20:54 ` [PATCH 1/2] drm/vmwgfx: use kzalloc in vmw_surface_define_ioctl() kbuild test robot
2015-09-30 21:08   ` Rasmus Villemoes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).