Skip to content

Commit 9b83c77

Browse files
error27konradwilk
authored andcommitted
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>
1 parent 6464920 commit 9b83c77

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/block/xen-blkback/blkback.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -809,11 +809,13 @@ static int __init xen_blkif_init(void)
809809
failed_init:
810810
kfree(blkbk->pending_reqs);
811811
kfree(blkbk->pending_grant_handles);
812-
for (i = 0; i < mmap_pages; i++) {
813-
if (blkbk->pending_pages[i])
814-
__free_page(blkbk->pending_pages[i]);
812+
if (blkbk->pending_pages) {
813+
for (i = 0; i < mmap_pages; i++) {
814+
if (blkbk->pending_pages[i])
815+
__free_page(blkbk->pending_pages[i]);
816+
}
817+
kfree(blkbk->pending_pages);
815818
}
816-
kfree(blkbk->pending_pages);
817819
kfree(blkbk);
818820
blkbk = NULL;
819821
return rc;

0 commit comments

Comments
 (0)