public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [MTD] potential division by 0 in cfi_build_cmd() and cfi_merge_status()?
@ 2008-01-15  0:28 Roel Kluin
  2008-01-15  3:01 ` Jörn Engel
  0 siblings, 1 reply; 4+ messages in thread
From: Roel Kluin @ 2008-01-15  0:28 UTC (permalink / raw)
  To: dwmw2; +Cc: linux-mtd

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-01-15  4:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-15  0:28 [MTD] potential division by 0 in cfi_build_cmd() and cfi_merge_status()? Roel Kluin
2008-01-15  3:01 ` Jörn Engel
2008-01-15  4:06   ` Nicolas Pitre
2008-01-15  4:10     ` Jörn Engel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox