public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Stefan Wahren <stefan.wahren@i2se.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: devel@driverdev.osuosl.org,
	Stefan Wahren <stefan.wahren@i2se.com>,
	Takashi Iwai <tiwai@suse.de>, Eric Anholt <eric@anholt.net>,
	linux-arm-kernel@lists.infradead.org,
	Dave Stevenson <dave.stevenson@raspberrypi.org>,
	Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Subject: [PATCH 01/10] staging: bcm2835-camera: Abort probe if there is no camera
Date: Thu,  6 Dec 2018 19:28:51 +0100	[thread overview]
Message-ID: <1544120940-13716-2-git-send-email-stefan.wahren@i2se.com> (raw)
In-Reply-To: <1544120940-13716-1-git-send-email-stefan.wahren@i2se.com>

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@i2se.com>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
---
 drivers/staging/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 c04bdf0..d6fbef7 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
+++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
@@ -1841,6 +1841,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;
 
@@ -1940,6 +1946,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.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2018-12-06 18:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-06 18:28 [PATCH 00/10] staging: vc04_services: Improve driver load/unload Stefan Wahren
2018-12-06 18:28 ` Stefan Wahren [this message]
2018-12-06 18:28 ` [PATCH 02/10] staging: bcm2835-camera: fix module autoloading Stefan Wahren
2018-12-06 18:28 ` [PATCH 03/10] staging: bcm2835-camera: Move module info to the end Stefan Wahren
2018-12-06 18:28 ` [PATCH 04/10] staging: vchiq_arm: Fix camera device registration Stefan Wahren
2018-12-06 18:28 ` [PATCH 05/10] staging: vchiq_arm: Register a platform device for audio Stefan Wahren
2018-12-06 18:28 ` [PATCH 06/10] staging: bcm2835-audio: Enable compile test Stefan Wahren
2018-12-06 18:28 ` [PATCH 07/10] staging: bcm2835-audio: use module_platform_driver() macro Stefan Wahren
2018-12-06 18:28 ` [PATCH 08/10] staging: bcm2835-audio: Drop DT dependency Stefan Wahren
2018-12-06 18:28 ` [PATCH 09/10] staging: bcm2835-camera: Provide more specific probe error messages Stefan Wahren
2018-12-06 18:29 ` [PATCH 10/10] staging: bcm2835-camera: Add hint about possible faulty config Stefan Wahren
2018-12-07  6:21 ` [PATCH 00/10] staging: vc04_services: Improve driver load/unload Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1544120940-13716-2-git-send-email-stefan.wahren@i2se.com \
    --to=stefan.wahren@i2se.com \
    --cc=dave.stevenson@raspberrypi.org \
    --cc=devel@driverdev.osuosl.org \
    --cc=eric@anholt.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=nsaenzjulienne@suse.de \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox