reset: fix reset_get_bulk when phandle error
authorNeil Armstrong <narmstrong@baylibre.com>
Tue, 17 Apr 2018 09:30:22 +0000 (11:30 +0200)
committerTom Rini <trini@konsulko.com>
Tue, 17 Apr 2018 21:45:08 +0000 (17:45 -0400)
This fixes the Coverity Defect CID 175348 when dev_count_phandle_with_args()
returns a negative value.

Fixes: 0c28233903b5 ("reset: Add get/assert/deassert/release for bulk of reset signals")
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
drivers/reset/reset-uclass.c

index 9a5c9c91b9db88114ff9a1d2ee3cff8e985e92e9..fa4f6538edd7fe6972839727f22e9787f775a0fa 100644 (file)
@@ -88,8 +88,8 @@ int reset_get_bulk(struct udevice *dev, struct reset_ctl_bulk *bulk)
        bulk->count = 0;
 
        count = dev_count_phandle_with_args(dev, "resets", "#reset-cells");
-       if (!count)
-               return 0;
+       if (count < 1)
+               return count;
 
        bulk->resets = devm_kcalloc(dev, count, sizeof(struct reset_ctl),
                                    GFP_KERNEL);