From patchwork Fri Aug 24 15:54:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Federico Fuga X-Patchwork-Id: 14033 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1T4wDR-000851-2a for patchwork@linuxtv.org; Fri, 24 Aug 2012 17:54:33 +0200 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.75/mailfrontend-3) with esmtp for id 1T4wDQ-0002Bj-Ew; Fri, 24 Aug 2012 17:54:33 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755973Ab2HXPya (ORCPT ); Fri, 24 Aug 2012 11:54:30 -0400 Received: from oproxy6-pub.bluehost.com ([67.222.54.6]:53463 "HELO oproxy6-pub.bluehost.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1755831Ab2HXPy3 (ORCPT ); Fri, 24 Aug 2012 11:54:29 -0400 Received: (qmail 29476 invoked by uid 0); 24 Aug 2012 15:54:24 -0000 Received: from unknown (HELO box484.bluehost.com) (66.147.242.84) by cpoproxy3.bluehost.com with SMTP; 24 Aug 2012 15:54:24 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=studiofuga.com; s=default; h=Message-Id:Date:Subject:Cc:To:From; bh=lXo3I9bsWBNAwfkQCB4BQHgxTs++fm3znol2Y1RNUUY=; b=INGOFhzr7OjnoarvulYjN4E/8gQc5kvXypEsFKeJLe3YaGW4Zk5R1/BkPWicqSYOWFDrrlu3oimIuL7JW+/0zIp1jias+wKpIko9PeMQCuC74yv455Q+ggj0aG+UEPA5; Received: from [95.241.194.105] (port=47116 helo=localhost) by box484.bluehost.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.76) (envelope-from ) id 1T4wDH-0003pa-CO; Fri, 24 Aug 2012 09:54:24 -0600 From: Federico Fuga To: Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, Federico Fuga Subject: [PATCH] Corrected Oops on omap_vout when no manager is connected Date: Fri, 24 Aug 2012 17:54:11 +0200 Message-Id: <1345823651-19800-1-git-send-email-fuga@studiofuga.com> X-Mailer: git-send-email 1.7.9.5 X-Identified-User: {2354:box484.bluehost.com:happycac:studiofuga.com} {sentby:smtp auth 95.241.194.105 authed with fuga+studiofuga.com} Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.8.24.154525 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_2000_2999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, RATWARE_LC_DIGITS_HELO 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_MEDIA_BODY 0, __CP_URI_IN_BODY 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __URI_NO_WWW 0, __URI_NS ' If no manager is connected to the vout device, the omapvid_init() function fails. No error condition is checked, and the device is started. Later on, when irq is serviced, a NULL pointer dereference occurs. Also, the isr routine must be registered only if no error occurs, otherwise the isr triggers without the proper setup, and the kernel oops again. To prevent this, the error condition is checked, and the streamon function exits with error. Also the isr registration call is moved after the setup procedure is completed. --- drivers/media/video/omap/omap_vout.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/media/video/omap/omap_vout.c b/drivers/media/video/omap/omap_vout.c index 15c5f4d..f456587 100644 --- a/drivers/media/video/omap/omap_vout.c +++ b/drivers/media/video/omap/omap_vout.c @@ -650,9 +650,12 @@ static void omap_vout_isr(void *arg, unsigned int irqstatus) /* First save the configuration in ovelray structure */ ret = omapvid_init(vout, addr); - if (ret) + if (ret) { printk(KERN_ERR VOUT_NAME "failed to set overlay info\n"); + goto vout_isr_err; + } + /* Enable the pipeline and set the Go bit */ ret = omapvid_apply_changes(vout); if (ret) @@ -1678,13 +1681,16 @@ static int vidioc_streamon(struct file *file, void *fh, enum v4l2_buf_type i) mask = DISPC_IRQ_VSYNC | DISPC_IRQ_EVSYNC_EVEN | DISPC_IRQ_EVSYNC_ODD | DISPC_IRQ_VSYNC2; - omap_dispc_register_isr(omap_vout_isr, vout, mask); - /* First save the configuration in ovelray structure */ ret = omapvid_init(vout, addr); - if (ret) + if (ret) { v4l2_err(&vout->vid_dev->v4l2_dev, "failed to set overlay info\n"); + goto streamon_err1; + } + + omap_dispc_register_isr(omap_vout_isr, vout, mask); + /* Enable the pipeline and set the Go bit */ ret = omapvid_apply_changes(vout); if (ret)