mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Jan Beulich <jbeulich@novell.com>,
	open list <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org
Subject: [patch] xen/blkback: potential null dereference in error handling
Date: Fri, 27 May 2011 09:27:16 +0300	[thread overview]
Message-ID: <20110527062701.GK14591@shale.localdomain> (raw)

blkbk->pending_pages can be NULL here so I added a check for it.

Signed-off-by: Dan Carpenter <error27@gmail.com>
---
Perhaps this is not the a very optimized solution, but it's error
handling code so it's not performance critical.

diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
index c73910c..1c7a59d 100644
--- a/drivers/block/xen-blkback/blkback.c
+++ b/drivers/block/xen-blkback/blkback.c
@@ -810,7 +810,7 @@ static int __init xen_blkif_init(void)
 	kfree(blkbk->pending_reqs);
 	kfree(blkbk->pending_grant_handles);
 	for (i = 0; i < mmap_pages; i++) {
-		if (blkbk->pending_pages[i])
+		if (blkbk->pending_pages && blkbk->pending_pages[i])
 			__free_page(blkbk->pending_pages[i]);
 	}
 	kfree(blkbk->pending_pages);

                 reply	other threads:[~2011-05-27  6:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110527062701.GK14591@shale.localdomain \
    --to=error27@gmail.com \
    --cc=jbeulich@novell.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®