drivers/gpu/drm/vmwgfx/vmwgfx_resource.c: alloc with no test
Hi Thomas,
FYI, coccinelle warns about
drivers/gpu/drm/vmwgfx/vmwgfx_resource.c:1355:1-13: alloc with no test, possible model on line 1402
vim +1355 drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
1345
1346 memcpy(srf->mip_levels, req->mip_levels, sizeof(srf->mip_levels));
1347 srf->num_sizes = num_sizes;
1348 user_srf->size = size;
1349
1350 srf->sizes = kmalloc(srf->num_sizes * sizeof(*srf->sizes), GFP_KERNEL);
1351 if (unlikely(srf->sizes = NULL)) {
1352 ret = -ENOMEM;
1353 goto out_no_sizes;
1354 }
Quoted 1 line
1355
srf->offsets= kmalloc(srf->num_sizes *sizeof(*srf->offsets),
1356 GFP_KERNEL);
1357 if (unlikely(srf->sizes = NULL)) {
1358 ret = -ENOMEM;
1359 goto out_no_offsets;
1360 }
1361
1362 user_sizes = (struct drm_vmw_size __user *)(unsigned long)
1363 req->size_addr;
1364
1365 ret = copy_from_user(srf->sizes, user_sizes,
Which is likely a copy/paste error introduced by commit
commit 5bb39e818169783ee17ddbbefbd7bd16a4383fec
Author: Thomas Hellstrom <[email protected]>
AuthorDate: Tue Oct 4 20:13:33 2011 +0200
Commit: Dave Airlie <[email protected]>
CommitDate: Wed Oct 5 10:17:31 2011 +0100Thanks,
Fengguang
Hi,
You're right. The line below tests for sizes instead of offsets. I'm about to fix this in an upcoming patch
series, so I won't submit a separate patch for this.
Thanks,
Thomas
Quoted 39 lines · Fengguang Wu
Hi Thomas,
FYI, coccinelle warns about
drivers/gpu/drm/vmwgfx/vmwgfx_resource.c:1355:1-13: alloc with no test, possible model on line 1402
vim +1355
drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
13451346 memcpy(srf->mip_levels, req->mip_levels, sizeof(srf->mip_levels)); 1347 srf->num_sizes = num_sizes; 1348 user_srf->size = size; 1349 1350 srf->sizes = kmalloc(srf->num_sizes * sizeof(*srf->sizes), GFP_KERNEL); 1351 if (unlikely(srf->sizes = NULL)) { 1352 ret = -ENOMEM; 1353 goto out_no_sizes; 1354 }Quoted 1 line
1355
srf->offsets= kmalloc(srf->num_sizes *sizeof(*srf->offsets),1356 GFP_KERNEL); 1357 if (unlikely(srf->sizes = NULL)) { 1358 ret = -ENOMEM; 1359 goto out_no_offsets; 1360 } 1361 1362 user_sizes = (struct drm_vmw_size __user *)(unsigned long) 1363 req->size_addr; 1364 1365 ret = copy_from_user(srf->sizes, user_sizes,Which is likely a copy/paste error introduced by commit
commit 5bb39e818169783ee17ddbbefbd7bd16a4383fec Author: Thomas Hellstrom <[email protected]> AuthorDate: Tue Oct 4 20:13:33 2011 +0200 Commit: Dave Airlie <[email protected]> CommitDate: Wed Oct 5 10:17:31 2011 +0100Thanks,
Fengguang
Thomas,
Quoted 5 lines · Thomas Hellstrom
Hi,
You're right. The line below tests for sizes instead of offsets. I'm about to fix this in an upcoming patch
series, so I won't submit a separate patch for this.
A separate fix would be more suitable for -stable backport?
Thanks,
Fengguang
Quoted 40 lines · Fengguang Wu
Quoted 39 lines
Hi Thomas,
FYI, coccinelle warns about
drivers/gpu/drm/vmwgfx/vmwgfx_resource.c:1355:1-13: alloc with no test, possible model on line 1402
vim +1355
drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
1345
1346memcpy(srf->mip_levels, req->mip_levels, sizeof(srf->mip_levels));
1347srf->num_sizes=num_sizes;
1348user_srf->size= size;
1349
1350srf->sizes=kmalloc(srf->num_sizes * sizeof(*srf->sizes), GFP_KERNEL);
1351 if (unlikely(srf->sizes = NULL)) {
1352 ret =-ENOMEM;
1353 gotoout_no_sizes;
1354 }Quoted 1 line
1355
srf->offsets= kmalloc(srf->num_sizes *sizeof(*srf->offsets),1356
GFP_KERNEL);
1357 if (unlikely(srf->sizes = NULL)) {
1358 ret =-ENOMEM;
1359 gotoout_no_offsets;
1360 }
1361
1362user_sizes= (structdrm_vmw_size__user*)(unsigned long)
1363req->size_addr;
1364
1365 ret = copy_from_user(srf->sizes,user_sizes,Which is likely a copy/paste error introduced by commit
commit 5bb39e818169783ee17ddbbefbd7bd16a4383fec Author: Thomas Hellstrom <[email protected]> AuthorDate: Tue Oct 4 20:13:33 2011 +0200 Commit: Dave Airlie <[email protected]> CommitDate: Wed Oct 5 10:17:31 2011 +0100Thanks,
Fengguang