All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@iki.fi>
To: linux-media@vger.kernel.org
Cc: linux-omap@vger.kernel.org, tony@atomide.com, sre@kernel.org,
	pali.rohar@gmail.com, laurent.pinchart@ideasonboard.com
Subject: [PATCH v2 02/15] omap3isp: Avoid a BUG_ON() in media_entity_create_link()
Date: Thu, 26 Mar 2015 00:57:26 +0200	[thread overview]
Message-ID: <1427324259-18438-3-git-send-email-sakari.ailus@iki.fi> (raw)
In-Reply-To: <1427324259-18438-1-git-send-email-sakari.ailus@iki.fi>

If an uninitialised v4l2_subdev struct was passed to
media_entity_create_link(), one of the BUG_ON()'s in the function will be
hit since media_entity.num_pads will be zero. Avoid this by checking whether
the num_pads field is non-zero for the interface.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/media/platform/omap3isp/isp.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c
index fb193b6..4ab674d 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -1946,6 +1946,19 @@ static int isp_register_entities(struct isp_device *isp)
 			goto done;
 		}
 
+		/*
+		 * Not all interfaces are available on all revisions
+		 * of the ISP. The sub-devices of those interfaces
+		 * aren't initialised in such a case. Check this by
+		 * ensuring the num_pads is non-zero.
+		 */
+		if (!input->num_pads) {
+			dev_err(isp->dev, "%s: invalid input %u\n",
+				entity->name, subdevs->interface);
+			ret = -EINVAL;
+			goto done;
+		}
+
 		for (i = 0; i < sensor->entity.num_pads; i++) {
 			if (sensor->entity.pads[i].flags & MEDIA_PAD_FL_SOURCE)
 				break;
-- 
1.7.10.4


  parent reply	other threads:[~2015-03-25 22:58 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-25 22:57 [PATCH v2 00/15] omap3isp driver DT support Sakari Ailus
2015-03-25 22:57 ` [PATCH v2 01/15] omap3isp: Fix error handling in probe Sakari Ailus
2015-03-25 22:57 ` Sakari Ailus [this message]
2015-03-25 22:57 ` [PATCH v2 03/15] omap3isp: Separate external link creation from platform data parsing Sakari Ailus
2015-03-25 22:57 ` [PATCH v2 04/15] omap3isp: DT support for clocks Sakari Ailus
2015-03-25 22:57 ` [PATCH v2 05/15] omap3isp: Platform data could be NULL Sakari Ailus
2015-03-25 22:57 ` [PATCH v2 06/15] omap3isp: Refactor device configuration structs for Device Tree Sakari Ailus
2015-03-25 23:21   ` Tony Lindgren
2015-03-25 22:57 ` [PATCH v2 07/15] omap3isp: Rename regulators to better suit the " Sakari Ailus
2015-03-25 22:57 ` [PATCH v2 08/15] omap3isp: Calculate vpclk_div for CSI-2 Sakari Ailus
2015-03-25 22:57 ` [PATCH v2 09/15] omap3isp: Replace mmio_base_phys array with the histogram block base Sakari Ailus
2015-03-25 22:57 ` [PATCH v2 10/15] omap3isp: Move the syscon register out of the ISP register maps Sakari Ailus
2015-03-25 22:57 ` [PATCH v2 11/15] omap3isp: Replace many MMIO regions by two Sakari Ailus
2015-03-25 22:57 ` [PATCH v2 12/15] dt: bindings: Add lane-polarity property to endpoint nodes Sakari Ailus
2015-04-24 19:41   ` Benoit Parrot
2015-04-24 19:41     ` Benoit Parrot
2015-04-24 19:49     ` Sakari Ailus
2015-04-24 19:53       ` Benoit Parrot
2015-04-24 19:53         ` Benoit Parrot
2015-03-25 22:57 ` [PATCH v2 13/15] v4l: of: Read lane-polarities endpoint property Sakari Ailus
2015-03-25 22:57 ` [PATCH v2 14/15] omap3isp: Add support for the Device Tree Sakari Ailus
2015-03-30 17:41   ` Sebastian Reichel
2015-03-30 21:17     ` Sakari Ailus
2015-03-30 23:13     ` [PATCH 1/1] omap3isp: Don't pass uninitialised arguments to of_graph_get_next_endpoint() Sakari Ailus
2015-03-31  1:37       ` Sebastian Reichel
2015-04-01 22:41         ` Sakari Ailus
2015-03-25 22:57 ` [PATCH v2 15/15] omap3isp: Deprecate platform data support Sakari Ailus

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=1427324259-18438-3-git-send-email-sakari.ailus@iki.fi \
    --to=sakari.ailus@iki.fi \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=pali.rohar@gmail.com \
    --cc=sre@kernel.org \
    --cc=tony@atomide.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.