From patchwork Thu Jan 10 10:04:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Neukum X-Patchwork-Id: 1959261 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 E6EB53FF0F for ; Thu, 10 Jan 2013 10:05:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752777Ab3AJKFB (ORCPT ); Thu, 10 Jan 2013 05:05:01 -0500 Received: from smtp-out002.kontent.com ([81.88.40.216]:44675 "EHLO smtp-out002.kontent.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752130Ab3AJKFA (ORCPT ); Thu, 10 Jan 2013 05:05:00 -0500 Received: from linux-5eaq.site (p4FFB02F7.dip.t-dialin.net [79.251.2.247]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: neukum_org@smtp-out002.kontent.com) by smtp-out002.kontent.com (Postfix) with ESMTPSA id 9C3C210038211; Thu, 10 Jan 2013 11:04:58 +0100 (CET) From: Oliver Neukum To: linux-usb@vger.kernel.org, laurent.pinchart@ideasonboard.com, tom.leiming@gmail.com, linux-media@vger.kernel.org Cc: Oliver Neukum Subject: [PATCH] uvc: fix race of open and suspend in error case Date: Thu, 10 Jan 2013 11:04:55 +0100 Message-Id: <1357812295-21174-1-git-send-email-oliver@neukum.org> X-Mailer: git-send-email 1.7.10.4 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Ming Lei reported: IMO, there is a minor fault in the error handling path of uvc_status_start() inside uvc_v4l2_open(), and the 'users' count should have been decreased before usb_autopm_put_interface(). In theory, the warning can be triggered when the device is opened just between usb_autopm_put_interface() and atomic_dec(&stream->dev->users). The fix is trivial. Signed-off-by:Oliver Neukum Reported-by: Ming Lei Signed-off-by: Oliver Neukum Signed-off-by: Laurent Pinchart --- drivers/media/usb/uvc/uvc_v4l2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c index f2ee8c6..74937b7 100644 --- a/drivers/media/usb/uvc/uvc_v4l2.c +++ b/drivers/media/usb/uvc/uvc_v4l2.c @@ -501,8 +501,8 @@ static int uvc_v4l2_open(struct file *file) if (atomic_inc_return(&stream->dev->users) == 1) { ret = uvc_status_start(stream->dev); if (ret < 0) { - usb_autopm_put_interface(stream->dev->intf); atomic_dec(&stream->dev->users); + usb_autopm_put_interface(stream->dev->intf); kfree(handle); return ret; }