From patchwork Fri Jul 11 21:25:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 4537651 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CF818C0514 for ; Fri, 11 Jul 2014 21:26:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DAAA420266 for ; Fri, 11 Jul 2014 21:26:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1794D2011E for ; Fri, 11 Jul 2014 21:26:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752373AbaGKV0A (ORCPT ); Fri, 11 Jul 2014 17:26:00 -0400 Received: from qmta07.emeryville.ca.mail.comcast.net ([76.96.30.64]:44080 "EHLO qmta07.emeryville.ca.mail.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751987AbaGKVZ7 (ORCPT ); Fri, 11 Jul 2014 17:25:59 -0400 Received: from omta13.emeryville.ca.mail.comcast.net ([76.96.30.52]) by qmta07.emeryville.ca.mail.comcast.net with comcast id R9Lr1o00117UAYkA79Ry4F; Fri, 11 Jul 2014 21:25:58 +0000 Received: from mail.gonehiking.org ([50.134.149.16]) by omta13.emeryville.ca.mail.comcast.net with comcast id R9Rx1o00G0MU7Qa8Z9Rx4b; Fri, 11 Jul 2014 21:25:58 +0000 Received: from lorien.sisa.samsung.com (lorien-wl.internal [192.168.1.40]) by mail.gonehiking.org (Postfix) with ESMTP id D2ABC3FD48; Fri, 11 Jul 2014 15:25:56 -0600 (MDT) From: Shuah Khan To: m.chehab@samsung.com Cc: Shuah Khan , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] media: em28xx - fix i2c_xfer to return -ENODEV when dev is removed Date: Fri, 11 Jul 2014 15:25:55 -0600 Message-Id: <1405113955-17073-1-git-send-email-shuah.kh@samsung.com> X-Mailer: git-send-email 1.9.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1405113958; bh=kRtt3YSPNRuqlsV9fsYIV6X6Us6vjJf5IKqK8+Udvmc=; h=Received:Received:Received:From:To:Subject:Date:Message-Id; b=UKZrL4ZFtb4vpJIl9Vn1dlG1B0zEK/9P6Pl4eG5bfA/XvyxuSXA0ESI8CHgU/IR/w NCOJEAjqZ74ZiAp3qtkohQnJ4dYVQZcEw6ntXTNXVUh7OtM6RFSa7Jb23K8N21SVgS vopjuGPgQq3v/M93hZoN7ODMcXo/u6fKVnYmkztxOVvad2Ljq1cw8GJO8Za3oc/xIc Bi0HXzhYADl5u9tgyr2gUaxN2wmuSyiKT00NmKPY0zJcbe14p1+EKb1LANIa9YDxPj 2I24+dG2qOeCQoFbDa+W0PfhDnv1WmVNkAy2Q2WBlwTX4NAQk/A+feJvGbmPXCpGqR fr9/JrSOOStxg== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In em28xx usb disconnect code path, some dvb fe and tuner drivers attempt i2c transfers from their release interfaces. When device is removed, return -ENODEV instead of attempting to transfer data over i2c. Signed-off-by: Shuah Khan --- drivers/media/usb/em28xx/em28xx-i2c.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/media/usb/em28xx/em28xx-i2c.c b/drivers/media/usb/em28xx/em28xx-i2c.c index b58d4eb..1048c1a 100644 --- a/drivers/media/usb/em28xx/em28xx-i2c.c +++ b/drivers/media/usb/em28xx/em28xx-i2c.c @@ -501,6 +501,12 @@ static int em28xx_i2c_xfer(struct i2c_adapter *i2c_adap, int addr, rc, i; u8 reg; + /* prevent i2c xfer attempts after device is disconnected + some fe's try to do i2c writes/reads from their release + interfaces when called in disconnect path */ + if (dev->disconnected) + return -ENODEV; + rc = rt_mutex_trylock(&dev->i2c_bus_lock); if (rc < 0) return rc;