From patchwork Thu Jul 26 11:59:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 1242251 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 C4BDE3FC5A for ; Thu, 26 Jul 2012 11:59:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752439Ab2GZL7U (ORCPT ); Thu, 26 Jul 2012 07:59:20 -0400 Received: from mail-gh0-f174.google.com ([209.85.160.174]:59240 "EHLO mail-gh0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752388Ab2GZL7R (ORCPT ); Thu, 26 Jul 2012 07:59:17 -0400 Received: by ghrr11 with SMTP id r11so1849047ghr.19 for ; Thu, 26 Jul 2012 04:59:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=4dUnDIwwFz6TH2fBQlZHUWC7hZzaMKyvk4oEGoRxjVw=; b=wDlDwGAP5RiMOiOdtyelewygkoJB8IgWFxPhPXfzEQcAt45301myPTgHtTQPnE50qO vTzwpOb8AuXcBi4OBmX7VpqcaCxHeGFVYSQxTZJZcjgxBrye2Dz8R8rE+ArWTVn+piRl CIdAJTGCBi7+lXjHv5yhmMZ6bwP6rvZ3qAxu3qyqSpngpQKk81z07FyDw73r3EgUWRet emVOAp2TmhcRYglnbyclVyhMtmnHIl/l2yKFRrZnmMi9XTMcI5QDHyBRaQ7r6C2rdSZj HGdL5Hvpsigke+ep+CwGnRgbc15ziFgixTJAmAsY5ImXujBMN775nKeoJ3A6u90Mu19N +5pQ== Received: by 10.236.115.103 with SMTP id d67mr27008238yhh.103.1343303956813; Thu, 26 Jul 2012 04:59:16 -0700 (PDT) Received: from localhost.localdomain ([186.153.120.250]) by mx.google.com with ESMTPS id e19sm21320418ann.10.2012.07.26.04.59.13 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 26 Jul 2012 04:59:14 -0700 (PDT) From: Ezequiel Garcia To: Mauro Carvalho Chehab Cc: Hans Verkuil , , Ezequiel Garcia Subject: [PATCH for v3.6] v4l2-dev.c: Move video_put() after debug printk Date: Thu, 26 Jul 2012 08:59:04 -0300 Message-Id: <1343303944-2652-1-git-send-email-elezegarcia@gmail.com> X-Mailer: git-send-email 1.7.4.4 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org It is possible that video_put() releases video_device struct, provoking a panic when debug printk wants to get video_device node name. Signed-off-by: Ezequiel Garcia Acked-by: Hans Verkuil --- drivers/media/video/v4l2-dev.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c index af70f93..3210fd5 100644 --- a/drivers/media/video/v4l2-dev.c +++ b/drivers/media/video/v4l2-dev.c @@ -478,12 +478,12 @@ static int v4l2_open(struct inode *inode, struct file *filp) } err: - /* decrease the refcount in case of an error */ - if (ret) - video_put(vdev); if (vdev->debug) printk(KERN_DEBUG "%s: open (%d)\n", video_device_node_name(vdev), ret); + /* decrease the refcount in case of an error */ + if (ret) + video_put(vdev); return ret; } @@ -500,12 +500,12 @@ static int v4l2_release(struct inode *inode, struct file *filp) if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags)) mutex_unlock(vdev->lock); } - /* decrease the refcount unconditionally since the release() - return value is ignored. */ - video_put(vdev); if (vdev->debug) printk(KERN_DEBUG "%s: release\n", video_device_node_name(vdev)); + /* decrease the refcount unconditionally since the release() + return value is ignored. */ + video_put(vdev); return ret; }