stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] v3.0.x: mtd: check partition count not partition array pointer
@ 2012-11-08  6:48 Anthony Foiani
  2012-11-29 21:38 ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Anthony Foiani @ 2012-11-08  6:48 UTC (permalink / raw)
  To: linux-kernel; +Cc: stable


mtd: check partition count not partition array pointer

The documentation claims that "nr_parts" is the determining factor,
while the code originally tested whether "parts" is non-null.

In at least one driver (fsl_elbc_nand), parts is never initialized to
0; even though nr_parts is correctly 0, add_mtd_partitions still tries
to create 0 partitions.)

Make the code adhere to the documentation.

A quick scan of all uses in the 3.0.51 kernel show that they correctly
rely on nr_parts rather than parts.

The current kernel has retired this function; I have not examined its
replacement to see if it has the same issue.

Signed-Off-By: Anthony Foiani <anthony.foiani@gmail.com>
---
 drivers/mtd/mtdcore.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index c510aff..ac624df 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -446,7 +446,7 @@ int mtd_device_register(struct mtd_info *master,
 			const struct mtd_partition *parts,
 			int nr_parts)
 {
-	return parts ? add_mtd_partitions(master, parts, nr_parts) :
+	return nr_parts ? add_mtd_partitions(master, parts, nr_parts) :
 		add_mtd_device(master);
 }
 EXPORT_SYMBOL_GPL(mtd_device_register);
--
1.7.11.7


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

end of thread, other threads:[~2012-12-01  0:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-08  6:48 [PATCH 1/1] v3.0.x: mtd: check partition count not partition array pointer Anthony Foiani
2012-11-29 21:38 ` Greg KH
2012-12-01  0:19   ` Anthony Foiani
2012-12-01  0:32     ` Greg KH
2012-12-01  0:56       ` Anthony Foiani

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).