Commit 7566f39d authored by Stefan Wahren's avatar Stefan Wahren Committed by Greg Kroah-Hartman

staging: bcm2835-camera: Abort probe if there is no camera

Abort the probing of the camera driver in case there isn't a camera
actually connected to the Raspberry Pi. This solution also avoids a
NULL ptr dereference of mmal instance on driver unload.

Fixes: 7b3ad5ab ("staging: Import the BCM2835 MMAL-based V4L2 camera driver.")
Signed-off-by: default avatarStefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: default avatarNicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 99c22707
...@@ -1841,6 +1841,12 @@ static int bcm2835_mmal_probe(struct platform_device *pdev) ...@@ -1841,6 +1841,12 @@ static int bcm2835_mmal_probe(struct platform_device *pdev)
num_cameras = get_num_cameras(instance, num_cameras = get_num_cameras(instance,
resolutions, resolutions,
MAX_BCM2835_CAMERAS); MAX_BCM2835_CAMERAS);
if (num_cameras < 1) {
ret = -ENODEV;
goto cleanup_mmal;
}
if (num_cameras > MAX_BCM2835_CAMERAS) if (num_cameras > MAX_BCM2835_CAMERAS)
num_cameras = MAX_BCM2835_CAMERAS; num_cameras = MAX_BCM2835_CAMERAS;
...@@ -1940,6 +1946,9 @@ static int bcm2835_mmal_probe(struct platform_device *pdev) ...@@ -1940,6 +1946,9 @@ static int bcm2835_mmal_probe(struct platform_device *pdev)
pr_info("%s: error %d while loading driver\n", pr_info("%s: error %d while loading driver\n",
BM2835_MMAL_MODULE_NAME, ret); BM2835_MMAL_MODULE_NAME, ret);
cleanup_mmal:
vchiq_mmal_finalise(instance);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment