From patchwork Sat Sep 15 16:06:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 1462411 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id B93B73FC33 for ; Sat, 15 Sep 2012 16:06:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751663Ab2IOQGj (ORCPT ); Sat, 15 Sep 2012 12:06:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:2520 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750942Ab2IOQGi (ORCPT ); Sat, 15 Sep 2012 12:06:38 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8FG6aAY012316 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 15 Sep 2012 12:06:36 -0400 Received: from localhost.localdomain (vpn1-6-252.gru2.redhat.com [10.97.6.252]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q8FG6YPN015898; Sat, 15 Sep 2012 12:06:35 -0400 Date: Sat, 15 Sep 2012 13:06:33 -0300 From: Mauro Carvalho Chehab To: Prabhakar Lad Cc: LMML Subject: Fw: [PATCH] Corrected Oops on omap_vout when no manager is connected Message-ID: <20120915130633.01414d71@redhat.com> Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Prabhakar, Please review. Thanks! Mauro Forwarded message: Date: Fri, 24 Aug 2012 17:54:11 +0200 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 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. Reviewed-by: Prabhakar Lad --- 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)