[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200116165502.8838-64-sashal@kernel.org>
Date: Thu, 16 Jan 2020 11:44:55 -0500
From: Sasha Levin <sashal@...nel.org>
To: linux-kernel@...r.kernel.org, stable@...r.kernel.org
Cc: Stefan Wahren <stefan.wahren@...e.com>,
Nicolas Saenz Julienne <nsaenzjulienne@...e.de>,
Dan Carpenter <dan.carpenter@...cle.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Sasha Levin <sashal@...nel.org>,
bcm-kernel-feedback-list@...adcom.com,
linux-rpi-kernel@...ts.infradead.org,
linux-arm-kernel@...ts.infradead.org, devel@...verdev.osuosl.org
Subject: [PATCH AUTOSEL 4.19 064/671] staging: bcm2835-camera: Abort probe if there is no camera
From: Stefan Wahren <stefan.wahren@...e.com>
[ Upstream commit 7566f39dfdc11f8a97d5810c6e6295a88f97ef91 ]
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: 7b3ad5abf027 ("staging: Import the BCM2835 MMAL-based V4L2 camera driver.")
Signed-off-by: Stefan Wahren <stefan.wahren@...e.com>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@...e.de>
Reviewed-by: Dan Carpenter <dan.carpenter@...cle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
.../vc04_services/bcm2835-camera/bcm2835-camera.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
index 455082867246..068e5b9ab232 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
+++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
@@ -1854,6 +1854,12 @@ static int bcm2835_mmal_probe(struct platform_device *pdev)
num_cameras = get_num_cameras(instance,
resolutions,
MAX_BCM2835_CAMERAS);
+
+ if (num_cameras < 1) {
+ ret = -ENODEV;
+ goto cleanup_mmal;
+ }
+
if (num_cameras > MAX_BCM2835_CAMERAS)
num_cameras = MAX_BCM2835_CAMERAS;
@@ -1953,6 +1959,9 @@ static int bcm2835_mmal_probe(struct platform_device *pdev)
pr_info("%s: error %d while loading driver\n",
BM2835_MMAL_MODULE_NAME, ret);
+cleanup_mmal:
+ vchiq_mmal_finalise(instance);
+
return ret;
}
--
2.20.1
Powered by blists - more mailing lists