mtd: physmap_of: fix set but unused warning
authorBrian Norris <computersforpeace@gmail.com>
Mon, 7 Mar 2016 23:52:05 +0000 (15:52 -0800)
committerBrian Norris <computersforpeace@gmail.com>
Sun, 10 Jul 2016 01:48:53 +0000 (18:48 -0700)
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@gmail.com>
drivers/mtd/maps/physmap_of.c

index 22f3858c0364688fb4f6e40a3fa11268ff7c8f49..3fad35942895c0186dfa08d22ab655fc0a4ed37f 100644 (file)
@@ -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;