media: m5mols: Check function pointer in m5mols_sensor_power
authorTom Rix <trix@redhat.com>
Sun, 19 Jul 2020 15:34:47 +0000 (17:34 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tue, 1 Sep 2020 12:13:27 +0000 (14:13 +0200)
clang static analysis reports this error

m5mols_core.c:767:4: warning: Called function pointer
  is null (null dereference) [core.CallAndMessage]
    info->set_power(&client->dev, 0);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In other places, the set_power ptr is checked.
So add a check.

Fixes: bc125106f8af ("[media] Add support for M-5MOLS 8 Mega Pixel camera ISP")
Signed-off-by: Tom Rix <trix@redhat.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/i2c/m5mols/m5mols_core.c

index de29511..21666d7 100644 (file)
@@ -764,7 +764,8 @@ static int m5mols_sensor_power(struct m5mols_info *info, bool enable)
 
                ret = regulator_bulk_enable(ARRAY_SIZE(supplies), supplies);
                if (ret) {
-                       info->set_power(&client->dev, 0);
+                       if (info->set_power)
+                               info->set_power(&client->dev, 0);
                        return ret;
                }