From patchwork Mon Mar 16 00:25:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 6014651 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6D8769F399 for ; Mon, 16 Mar 2015 00:27:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AEDAF202E6 for ; Mon, 16 Mar 2015 00:27:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1743C202F8 for ; Mon, 16 Mar 2015 00:27:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752791AbbCPA1A (ORCPT ); Sun, 15 Mar 2015 20:27:00 -0400 Received: from nblzone-211-213.nblnetworks.fi ([83.145.211.213]:45054 "EHLO hillosipuli.retiisi.org.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750937AbbCPA05 (ORCPT ); Sun, 15 Mar 2015 20:26:57 -0400 Received: from lanttu.localdomain (lanttu.localdomain [192.168.5.64]) by hillosipuli.retiisi.org.uk (Postfix) with ESMTP id 7AE3B60097; Mon, 16 Mar 2015 02:26:54 +0200 (EET) From: Sakari Ailus 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 02/15] omap3isp: Avoid a BUG_ON() in media_entity_create_link() Date: Mon, 16 Mar 2015 02:25:57 +0200 Message-Id: <1426465570-30295-3-git-send-email-sakari.ailus@iki.fi> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1426465570-30295-1-git-send-email-sakari.ailus@iki.fi> References: <1426465570-30295-1-git-send-email-sakari.ailus@iki.fi> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Laurent Pinchart --- 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;