From patchwork Mon Jul 11 10:41:49 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 963942 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p6BAfrKN028597 for ; Mon, 11 Jul 2011 10:41:53 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753465Ab1GKKlv (ORCPT ); Mon, 11 Jul 2011 06:41:51 -0400 Received: from ppsw-51.csi.cam.ac.uk ([131.111.8.151]:32974 "EHLO ppsw-51.csi.cam.ac.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753194Ab1GKKlu (ORCPT ); Mon, 11 Jul 2011 06:41:50 -0400 X-Cam-AntiVirus: no malware found X-Cam-SpamDetails: not scanned X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from arcturus.eng.cam.ac.uk ([129.169.154.73]:52844) by ppsw-51.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.158]:25) with esmtpsa (PLAIN:jic23) (TLSv1:DHE-RSA-CAMELLIA256-SHA:256) id 1QgDvx-00067P-X5 (Exim 4.72) (return-path ); Mon, 11 Jul 2011 11:41:49 +0100 Message-ID: <4E1AD36D.4030702@cam.ac.uk> Date: Mon, 11 Jul 2011 11:41:49 +0100 From: Jonathan Cameron User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110509 Lightning/1.0b3pre Thunderbird/3.1.10 MIME-Version: 1.0 To: Laurent Pinchart , Linux Media Mailing List Subject: Error routes through omap3isp ccdc. X-Enigmail-Version: 1.1.2 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 11 Jul 2011 10:41:53 +0000 (UTC) Hi All, Came across this when my camera driver failed to load.. Following causes a kernel panic. Set up link between cdcc and ccdc output to memory. (at this point intitializing a capture gives an invalid arguement error which is fine.) Now set the format on ISP CCDC/0 to SGRBG10 752x480 (doubt what these settings are actually matters). Actually come to think of it, this may only be relevant as otherwise, the format of my attempted stream setup from userspace doesn't matter. Blithely attempt to grab frames from userspace off the ccdc output. (note it has no input.) Null pointer exception occurs because: pad = media_entity_remote_source(&ccdc->pads[CCDC_PAD_SINK]); in static void ccdc_configure(struct isp_ccdc_device *ccdc) returns null and this is not checked. Obvious local fix is to check the value of pad and allow ccdc_configure to return an error + pass this up out of ccdc_set_stream. Something like the following does the trick. (not sure error code is right choice!) Patch is against todays linux-next + a few unconnected things to make that tree actually build for the beagle xm. Grep isn't indicating any exactly matching cases to this problem, so the rest of the tree may be fine. [PATCH] omap3isp: check if there is actually a source for ispccdc when setting up the link. Without this if no source actually exists and the ccdc is configured to output to memory, a read from userspace will cause a null pointer exception. Signed-off-by: Jonathan Cameron --- drivers/media/video/omap3isp/ispccdc.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/media/video/omap3isp/ispccdc.c b/drivers/media/video/omap3isp/ispccdc.c index 6766247..2703a94 100644 --- a/drivers/media/video/omap3isp/ispccdc.c +++ b/drivers/media/video/omap3isp/ispccdc.c @@ -1110,7 +1110,7 @@ static const u32 ccdc_sgbrg_pattern = ISPCCDC_COLPTN_R_Ye << ISPCCDC_COLPTN_CP3PLC2_SHIFT | ISPCCDC_COLPTN_Gr_Cy << ISPCCDC_COLPTN_CP3PLC3_SHIFT; -static void ccdc_configure(struct isp_ccdc_device *ccdc) +static int ccdc_configure(struct isp_ccdc_device *ccdc) { struct isp_device *isp = to_isp_device(ccdc); struct isp_parallel_platform_data *pdata = NULL; @@ -1127,6 +1127,8 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc) u32 ccdc_pattern; pad = media_entity_remote_source(&ccdc->pads[CCDC_PAD_SINK]); + if (pad == NULL) + return -ENODEV; sensor = media_entity_to_v4l2_subdev(pad->entity); if (ccdc->input == CCDC_INPUT_PARALLEL) pdata = &((struct isp_v4l2_subdevs_group *)sensor->host_priv) @@ -1257,6 +1259,7 @@ unlock: spin_unlock_irqrestore(&ccdc->lsc.req_lock, flags); ccdc_apply_controls(ccdc); + return 0; } static void __ccdc_enable(struct isp_ccdc_device *ccdc, int enable) @@ -1726,7 +1729,9 @@ static int ccdc_set_stream(struct v4l2_subdev *sd, int enable) isp_reg_set(isp, OMAP3_ISP_IOMEM_CCDC, ISPCCDC_CFG, ISPCCDC_CFG_VDLC); - ccdc_configure(ccdc); + ret = ccdc_configure(ccdc); + if (ret < 0) + return ret; /* TODO: Don't configure the video port if all of its output * links are inactive.