diff options
author | Dan Carpenter <error27@gmail.com> | 2011-05-27 08:27:16 +0200 |
---|---|---|
committer | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 2011-06-01 15:28:21 +0200 |
commit | 9b83c771214cf6a256ee875050e6eaf320cf7983 (patch) | |
tree | 39b5308ea40a47d19cefab98721402296b78a246 /drivers/block/xen-blkback | |
parent | xen/blkback: don't call vbd_size() if bd_disk is NULL (diff) | |
download | linux-9b83c771214cf6a256ee875050e6eaf320cf7983.tar.xz linux-9b83c771214cf6a256ee875050e6eaf320cf7983.zip |
xen/blkback: potential null dereference in error handling
blkbk->pending_pages can be NULL here so I added a check for it.
Signed-off-by: Dan Carpenter <error27@gmail.com>
[v1: Redid the loop a bit]
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'drivers/block/xen-blkback')
-rw-r--r-- | drivers/block/xen-blkback/blkback.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c index c73910cc28c9..5cf2993a8338 100644 --- a/drivers/block/xen-blkback/blkback.c +++ b/drivers/block/xen-blkback/blkback.c @@ -809,11 +809,13 @@ static int __init xen_blkif_init(void) failed_init: kfree(blkbk->pending_reqs); kfree(blkbk->pending_grant_handles); - for (i = 0; i < mmap_pages; i++) { - if (blkbk->pending_pages[i]) - __free_page(blkbk->pending_pages[i]); + if (blkbk->pending_pages) { + for (i = 0; i < mmap_pages; i++) { + if (blkbk->pending_pages[i]) + __free_page(blkbk->pending_pages[i]); + } + kfree(blkbk->pending_pages); } - kfree(blkbk->pending_pages); kfree(blkbk); blkbk = NULL; return rc; |