From: Roel Kluin <12o3l@tiscali.nl>
To: dwmw2@infradead.org
Cc: linux-mtd@lists.infradead.org
Subject: [MTD] potential division by 0 in cfi_build_cmd() and cfi_merge_status()?
Date: Tue, 15 Jan 2008 01:28:12 +0100 [thread overview]
Message-ID: <478BFE1C.1090608@tiscali.nl> (raw)
Doing some grepping, I stumbled upon this possible error:
in include/linux/mtd/cfi.h, lines 302 and 366, resp. functions
cfi_build_cmd() and cfi_merge_status() there is a division by
cfi_interleave(cfi):
chip_mode = map_bankwidth(map) / cfi_interleave(cfi);
This could be problematic when No CONFIG_MTD_CFI_Ix is selected:
cfi_interleave will triggers BUG(), but when BUG is disabled, the
function returns 0, causing a subsequent division by zero.
When a CONFIG_MTD_CFI_Ix is selected, cfi_interleave(cfi) is either
defined 1 or defined (cfi)->interleave.
cfi is a struct cfi_private pointer, with interleave as an int.
I am not sure whether interleave can ever be 0 in this division when
CONFIG_MTD_CFI_Ix is set.
shouldn't there be an error exit when cfi_interleave(cfi) evaluates
to 0?
I am not subscribed to this list, so please CC.
Roel
next reply other threads:[~2008-01-15 0:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-15 0:28 Roel Kluin [this message]
2008-01-15 3:01 ` [MTD] potential division by 0 in cfi_build_cmd() and cfi_merge_status()? Jörn Engel
2008-01-15 4:06 ` Nicolas Pitre
2008-01-15 4:10 ` Jörn Engel
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=478BFE1C.1090608@tiscali.nl \
--to=12o3l@tiscali.nl \
--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