Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1236761

Re: [PATCH 1/2] drm/vmwgfx: use kzalloc in vmw_surface_define_ioctl()

From Rasmus Villemoes <linux@rasmusvillemoes.dk>
Newsgroups linux.kernel
Subject Re: [PATCH 1/2] drm/vmwgfx: use kzalloc in vmw_surface_define_ioctl()
Date 2015-09-30 23:10 +0200
Message-ID <qewNr-8fj-1@gated-at.bofh.it> (permalink)
References <qewDL-7OB-7@gated-at.bofh.it>
Organization D03

Show all headers | View raw


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;
 	}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 1/2] drm/vmwgfx: use kzalloc in vmw_surface_define_ioctl() Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-09-30 22:00 +0200
  Re: [PATCH 1/2] drm/vmwgfx: use kzalloc in vmw_surface_define_ioctl() kbuild test robot <lkp@intel.com> - 2015-09-30 23:00 +0200
    Re: [PATCH 1/2] drm/vmwgfx: use kzalloc in vmw_surface_define_ioctl() Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-09-30 23:10 +0200

csiph-web