From patchwork Thu Oct 14 16:30:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 253501 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o9EGV332001322 for ; Thu, 14 Oct 2010 16:31:03 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753066Ab0JNQav (ORCPT ); Thu, 14 Oct 2010 12:30:51 -0400 Received: from mail-px0-f174.google.com ([209.85.212.174]:38025 "EHLO mail-px0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752677Ab0JNQau (ORCPT ); Thu, 14 Oct 2010 12:30:50 -0400 Received: by pxi16 with SMTP id 16so978704pxi.19 for ; Thu, 14 Oct 2010 09:30:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:content-type :content-transfer-encoding; bh=P5HlTRwNj0O/e0g0O9F5aRtBVBl6GAJYTMc+W4CYURo=; b=RlcihPq7M32qGdSoJjKqHJICtpY2fjGM17nnBHpuSSjiS+yAuWVE+DIdbprwpgsbjz BKyOBxuIJGZRmGE8QYsQjjQYt9x6sH8Ky5FDgTaSvJrJB4VKZ+fdQgWKpddFkGjOnjHP gOzfYZ0iwoD6wAk9eiAveP9VCRtWsgDEdGeDg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; b=chqrqIRtsYyAWy4TfIyd4ci6cwTLx/0o127773XgB8FMuoe/Iq6tSQVTWhxNR/nh8A MJ0CZ5jXfXxVrhbg4j6m+x3LLcqkdLMla0Vh52LuNy1KhDmc3/jVpDE+b7vLHgeQl38P F84GKT527raAjvNXwynu1iPQsKkzW7l7MMhno= Received: by 10.142.245.13 with SMTP id s13mr9036078wfh.149.1287073849517; Thu, 14 Oct 2010 09:30:49 -0700 (PDT) Received: from [192.168.30.170] (201-68-231-211.dsl.telesp.net.br [201.68.231.211]) by mx.google.com with ESMTPS id k15sm722180qcu.11.2010.10.14.09.30.46 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 14 Oct 2010 09:30:47 -0700 (PDT) Message-ID: <4CB73034.5040208@gmail.com> Date: Thu, 14 Oct 2010 13:30:44 -0300 From: Mauro Carvalho Chehab User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100827 Red Hat/3.1.3-1.el6 Lightning/1.0b2 Thunderbird/3.1.3 MIME-Version: 1.0 To: Linux Media Mailing List Subject: [PATCH] V4L/DVB: ir: avoid race conditions at device disconnect - was: Fwd: Re: *buntu 10.10 rc Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Thu, 14 Oct 2010 16:31:04 +0000 (UTC) diff --git a/drivers/media/IR/ir-sysfs.c b/drivers/media/IR/ir-sysfs.c index dab074e..949b055 100644 --- a/drivers/media/IR/ir-sysfs.c +++ b/drivers/media/IR/ir-sysfs.c @@ -68,6 +68,10 @@ static ssize_t show_protocols(struct device *d, char *tmp = buf; int i; + /* Device is being removed */ + if (!ir_dev) + return -EINVAL; + if (ir_dev->props->driver_type == RC_DRIVER_SCANCODE) { enabled = ir_dev->rc_tab.ir_type; allowed = ir_dev->props->allowed_protos; @@ -122,6 +126,10 @@ static ssize_t store_protocols(struct device *d, int rc, i, count = 0; unsigned long flags; + /* Device is being removed */ + if (!ir_dev) + return -EINVAL; + if (ir_dev->props && ir_dev->props->driver_type == RC_DRIVER_SCANCODE) type = ir_dev->rc_tab.ir_type; else @@ -305,6 +313,7 @@ void ir_unregister_class(struct input_dev *input_dev) { struct ir_input_dev *ir_dev = input_get_drvdata(input_dev); + input_set_drvdata(input_dev, NULL); clear_bit(ir_dev->devno, &ir_core_dev_number); input_unregister_device(input_dev); device_del(&ir_dev->dev);