From 4beea0c16ceaefc78e2fb6b5a2a0548bd6d04ee6 Mon Sep 17 00:00:00 2001
From: Dave Stevenson <dave.stevenson@raspberrypi.org>
Date: Thu, 10 May 2018 12:42:14 -0700
Subject: [PATCH 374/454] staging: bcm2835-camera: Replace BUG_ON with return
 error

commit 84db34cd720964adf0c9019d6d1b4de1cb26d1de upstream.

The error conditions don't warrant taking the kernel down, so remove
BUG_ON.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
Signed-off-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 .../staging/vc04_services/bcm2835-camera/bcm2835-camera.c  | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

--- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
+++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
@@ -304,8 +304,8 @@ static int buffer_prepare(struct vb2_buf
 	v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, "%s: dev:%p, vb %p\n",
 		 __func__, dev, vb);
 
-	BUG_ON(!dev->capture.port);
-	BUG_ON(!dev->capture.fmt);
+	if (!dev->capture.port || !dev->capture.fmt)
+		return -ENODEV;
 
 	size = dev->capture.stride * dev->capture.height;
 	if (vb2_plane_size(vb, 0) < size) {
@@ -1050,7 +1050,8 @@ static int mmal_setup_components(struct
 	struct mmal_fmt *mfmt = get_format(f);
 	u32 remove_padding;
 
-	BUG_ON(!mfmt);
+	if (!mfmt)
+		return -EINVAL;
 
 	if (dev->capture.encode_component) {
 		v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev,
