mtd: physmap_of: fix set but unused warning

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Mon Aug 1 18:59:02 PDT 2016


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=b137aab438382fdadfe1272869357485af0252b4
Commit:     b137aab438382fdadfe1272869357485af0252b4
Parent:     c3cb77f8980db9dba614822d2d4a4cc61e44c8e2
Author:     Brian Norris <computersforpeace at gmail.com>
AuthorDate: Mon Mar 7 15:52:05 2016 -0800
Committer:  Brian Norris <computersforpeace at gmail.com>
CommitDate: Sat Jul 9 18:48:53 2016 -0700

    mtd: physmap_of: fix set but unused warning
    
    drivers/mtd/maps/physmap_of.c: In function ‘of_flash_probe’:
    drivers/mtd/maps/physmap_of.c:165:16: warning: variable ‘p’ set but not used [-Wunused-but-set-variable]
    
    This could be a problem if the 'reg' property is not set, since that
    means 'count' will be uninitialized.
    
    Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
 drivers/mtd/maps/physmap_of.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c
index 22f3858..3fad359 100644
--- a/drivers/mtd/maps/physmap_of.c
+++ b/drivers/mtd/maps/physmap_of.c
@@ -186,7 +186,7 @@ static int of_flash_probe(struct platform_device *dev)
 	 * consists internally of 2 non-identical NOR chips on one die.
 	 */
 	p = of_get_property(dp, "reg", &count);
-	if (count % reg_tuple_size != 0) {
+	if (!p || count % reg_tuple_size != 0) {
 		dev_err(&dev->dev, "Malformed reg property on %s\n",
 				dev->dev.of_node->full_name);
 		err = -EINVAL;



More information about the linux-mtd-cvs mailing list