From patchwork Tue Nov 29 02:15:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 9450843 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9F7CB600CB for ; Tue, 29 Nov 2016 02:16:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9020C280F4 for ; Tue, 29 Nov 2016 02:16:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 843D628113; Tue, 29 Nov 2016 02:16:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26AE5280F4 for ; Tue, 29 Nov 2016 02:16:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756063AbcK2CPg (ORCPT ); Mon, 28 Nov 2016 21:15:36 -0500 Received: from ec2-52-27-115-49.us-west-2.compute.amazonaws.com ([52.27.115.49]:42860 "EHLO osg.samsung.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755973AbcK2CPW (ORCPT ); Mon, 28 Nov 2016 21:15:22 -0500 Received: from localhost (localhost [127.0.0.1]) by osg.samsung.com (Postfix) with ESMTP id C6C61A1355; Tue, 29 Nov 2016 02:15:32 +0000 (UTC) X-Virus-Scanned: amavisd-new at osg.samsung.com X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from osg.samsung.com ([127.0.0.1]) by localhost (s-opensource.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9EBQLejF9T-p; Tue, 29 Nov 2016 02:15:31 +0000 (UTC) Received: from localhost.localdomain (c-73-181-52-62.hsd1.co.comcast.net [73.181.52.62]) by osg.samsung.com (Postfix) with ESMTPSA id 14012A1313; Tue, 29 Nov 2016 02:15:31 +0000 (UTC) From: Shuah Khan To: mchehab@kernel.org, mkrufky@linuxtv.org, klock.android@gmail.com, elfring@users.sourceforge.net, max@duempel.org, hans.verkuil@cisco.com, javier@osg.samsung.com, chehabrafael@gmail.com, sakari.ailus@linux.intel.com, laurent.pinchart+renesas@ideasonboard.com Cc: Shuah Khan , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] media: au0828 fix to protect enable/disable source set and clear Date: Mon, 28 Nov 2016 19:15:13 -0700 Message-Id: <6a4776ad1450ecf6ce73e5c005e0549fc29e7710.1480384155.git.shuahkh@osg.samsung.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: References: In-Reply-To: References: Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Protect enable/disable source set and clear to avoid races with callers. There is a possibility clear could occur while dvb-core and v4l2 try to access these handlers. Signed-off-by: Shuah Khan --- drivers/media/usb/au0828/au0828-core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c index bf53553..a1f696a 100644 --- a/drivers/media/usb/au0828/au0828-core.c +++ b/drivers/media/usb/au0828/au0828-core.c @@ -153,9 +153,11 @@ static void au0828_unregister_media_device(struct au0828_dev *dev) } /* clear enable_source, disable_source */ + mutex_lock(&mdev->graph_mutex); dev->media_dev->source_priv = NULL; dev->media_dev->enable_source = NULL; dev->media_dev->disable_source = NULL; + mutex_unlock(&mdev->graph_mutex); media_device_unregister(dev->media_dev); media_device_cleanup(dev->media_dev); @@ -549,9 +551,11 @@ static int au0828_media_device_register(struct au0828_dev *dev, return ret; } /* set enable_source */ + mutex_lock(&dev->media_dev->graph_mutex); dev->media_dev->source_priv = (void *) dev; dev->media_dev->enable_source = au0828_enable_source; dev->media_dev->disable_source = au0828_disable_source; + mutex_unlock(&dev->media_dev->graph_mutex); #endif return 0; }