diff options
author | Julia Lawall <julia@diku.dk> | 2011-07-09 15:23:26 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-08-02 19:12:49 -0400 |
commit | fe3e593601752d547bd00d83f0bdedbce1d80f59 (patch) | |
tree | 153f35363ec1c74c545345398876ea7f3a75d233 /drivers | |
parent | 55dc6ee7def173f0dd3b6d0d0257917112d542e9 (diff) |
drivers/staging/hv/blkvsc_drv.c: eliminate NULL pointer dereference
In this code, blkvsc_req is allocated in the cache blkdev->request_pool,
but freed in the first case to the cache blkvsc_req->dev->request_pool.
blkvsc_req->dev is subsequently initialized to blkdev, making these the
same at the second call to kmem_cache_free. But at the point of the first
call, blkvsc_req->dev is NULL. The second call is changed too, for
uniformity.
The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression x,e,e1,e2,e3;
@@
x = \(kmem_cache_alloc\|kmem_cache_zalloc\)(e1,e2)
... when != x = e
(
kmem_cache_free(e1,x);
|
?-kmem_cache_free(e3,x);
+kmem_cache_free(e1,x);
)
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Cc: KY Srinivasan <kys@microsoft.com>
Cc: Hank Janssen <hjanssen@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/hv/blkvsc_drv.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index 3612574ca520..d286b2223181 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c | |||
@@ -325,7 +325,7 @@ static int blkvsc_do_operation(struct block_device_context *blkdev, | |||
325 | 325 | ||
326 | page_buf = alloc_page(GFP_KERNEL); | 326 | page_buf = alloc_page(GFP_KERNEL); |
327 | if (!page_buf) { | 327 | if (!page_buf) { |
328 | kmem_cache_free(blkvsc_req->dev->request_pool, blkvsc_req); | 328 | kmem_cache_free(blkdev->request_pool, blkvsc_req); |
329 | return -ENOMEM; | 329 | return -ENOMEM; |
330 | } | 330 | } |
331 | 331 | ||
@@ -422,7 +422,7 @@ cleanup: | |||
422 | 422 | ||
423 | __free_page(page_buf); | 423 | __free_page(page_buf); |
424 | 424 | ||
425 | kmem_cache_free(blkvsc_req->dev->request_pool, blkvsc_req); | 425 | kmem_cache_free(blkdev->request_pool, blkvsc_req); |
426 | 426 | ||
427 | return ret; | 427 | return ret; |
428 | } | 428 | } |