Add check for a NULL value of the loadfirmware_handler to fix the following smatch error: drivers/media/common/siano/smscoreapi.c:1172 smscore_load_firmware_from_file() error: we previously assumed 'loadfirmware_handler' could be null (see line 1150) Note that it is a false positive, but frankly, this change makes the code more robust. Signed-off-by: Hans Verkuil <hverkuil-cisco@xxxxxxxxx> --- drivers/media/common/siano/smscoreapi.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/media/common/siano/smscoreapi.c b/drivers/media/common/siano/smscoreapi.c index b6f1eb5dbbdf..329aee411562 100644 --- a/drivers/media/common/siano/smscoreapi.c +++ b/drivers/media/common/siano/smscoreapi.c @@ -1166,10 +1166,15 @@ static int smscore_load_firmware_from_file(struct smscore_device_t *coredev, memcpy(fw_buf, fw->data, fw->size); fw_buf_size = fw->size; + /* + * Note that loadfirmware_handler can't be NULL due to the + * check above, but it is confusing smatch. + */ rc = (coredev->device_flags & SMS_DEVICE_FAMILY2) ? - smscore_load_firmware_family2(coredev, fw_buf, fw_buf_size) - : loadfirmware_handler(coredev->context, fw_buf, - fw_buf_size); + smscore_load_firmware_family2(coredev, fw_buf, fw_buf_size) : + (loadfirmware_handler ? + loadfirmware_handler(coredev->context, fw_buf, fw_buf_size) : + -EINVAL); } kfree(fw_buf); -- 2.43.0