public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Richard Genoud <richard.genoud@gmail.com>
To: David Woodhouse <dwmw2@infradead.org>,
	Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Cc: Richard Genoud <richard.genoud@gmail.com>,
	linux-mtd@lists.infradead.org,
	Adrian Hunter <adrian.hunter@intel.com>
Subject: [PATCH] MTD: nandsim: BUG: Fail if overridesize is too big
Date: Wed, 12 Sep 2012 14:26:26 +0200	[thread overview]
Message-ID: <1347452786-10208-1-git-send-email-richard.genoud@gmail.com> (raw)

If override size is too big, the module was actually loaded instead of
failing, because retval was not set.

This lead to memory corruption with the use of the freed structs nandsim
and nand_chip.

Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
---
 drivers/mtd/nand/nandsim.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
index cf0cd31..5d881180 100644
--- a/drivers/mtd/nand/nandsim.c
+++ b/drivers/mtd/nand/nandsim.c
@@ -2333,6 +2333,7 @@ static int __init ns_init_module(void)
 		uint64_t new_size = (uint64_t)nsmtd->erasesize << overridesize;
 		if (new_size >> overridesize != nsmtd->erasesize) {
 			NS_ERR("overridesize is too big\n");
+			retval = -EINVAL;
 			goto err_exit;
 		}
 		/* N.B. This relies on nand_scan not doing anything with the size before we change it */
-- 
1.7.2.5

             reply	other threads:[~2012-09-12 12:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-12 12:26 Richard Genoud [this message]
2012-09-18  8:27 ` [PATCH] MTD: nandsim: BUG: Fail if overridesize is too big Richard Genoud
2012-09-26  9:52   ` Artem Bityutskiy
2012-09-25 14:05 ` Artem Bityutskiy

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=1347452786-10208-1-git-send-email-richard.genoud@gmail.com \
    --to=richard.genoud@gmail.com \
    --cc=adrian.hunter@intel.com \
    --cc=artem.bityutskiy@linux.intel.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-mtd@lists.infradead.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