Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp2052137pxy; Mon, 2 Aug 2021 17:59:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5wwSCmGfyOR3lEW2NxRaxkslx3XLqWHK81arwgJrTSQYG40Y9KUgmhN2jQ08b8axluH/5 X-Received: by 2002:a05:6638:95:: with SMTP id v21mr10510518jao.80.1627952376583; Mon, 02 Aug 2021 17:59:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627952376; cv=none; d=google.com; s=arc-20160816; b=1HLCM/24zGeuN6AODJnopZxhJAF36vvAcc1cToWNGVpszomDRgQ+nyu700IG/8LFDJ BErOJ+aOTssHcMTT8byd0D0rgxq/wL3ZUqwMm+lCX9YxXhizmOixxWDKC0AxHnUnXQ9S Hbe1WsIRBLZlnggkgeX1p1/WpKHrd+oH6+i8+zAarKEoTN/Gem6vC0PILm9ZgfepPaYg x4KhHteEMPgO3ognF7imqkuB4z5NkP8qtD9karYyGlV5A3LeyF84PO+d6S/EoMHDIgjt 1NsNsBscqCUMX5LjyYE3YGjuiZz0E7y3XZxibs7Vz2IWFydpHkeRHWbJPiivf/2K0UUL lX1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=hncDtFE33CceBPAZt8tzczjPrNPGTZeh8t2SDxffcf8=; b=x8WPQSrxOTdV1iUktQ0TGydtwBx+c6/zLHhFUGpD0PkAsrtJC0mCtMyCoD10PTXHyx 2J3xO2sp0dMjaA41/R5wI1EqAAFcUGjR0Y/BDMrUSBYz+pYNGWlwjo+E+ypz/5YypAB7 4pFE14UjsCHVi8DOKTEy6n3u3sNdb0VGSi1Vrm9Mrj4Luke+GFn5WglhPENRxPZxE1qN eMhH+oxPS9HqgMXdz2lkE3WQc6o+HGjlFk/FfO1Ca3TlJ2xMpv6bSuLwmcyFNOMT+/WQ +woOAIvPiAFzJM7c4DknfMIzoAfRHCcrhJ4605KncO9XOQRR7wjQvofCy50G5FJXPrUo vydg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b3si14228737iln.124.2021.08.02.17.59.24; Mon, 02 Aug 2021 17:59:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233310AbhHCA6q (ORCPT + 99 others); Mon, 2 Aug 2021 20:58:46 -0400 Received: from netrider.rowland.org ([192.131.102.5]:33039 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S232879AbhHCA6p (ORCPT ); Mon, 2 Aug 2021 20:58:45 -0400 Received: (qmail 350320 invoked by uid 1000); 2 Aug 2021 20:58:34 -0400 Date: Mon, 2 Aug 2021 20:58:34 -0400 From: Alan Stern To: Salah Triki Cc: Keith Packard , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] usb: misc: chaoskey: get lock before calling usb_[disable|enable]_autosuspend() Message-ID: <20210803005834.GB349864@rowland.harvard.edu> References: <20210802222205.GA1389315@pc> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210802222205.GA1389315@pc> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 02, 2021 at 11:22:05PM +0100, Salah Triki wrote: > Based on the documentation of usb_[disable|enable]_autosuspend(), the > caller must hold udev's device lock. > > Signed-off-by: Salah Triki > --- > drivers/usb/misc/chaoskey.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/usb/misc/chaoskey.c b/drivers/usb/misc/chaoskey.c > index 87067c3d6109..8af00be7b9e8 100644 > --- a/drivers/usb/misc/chaoskey.c > +++ b/drivers/usb/misc/chaoskey.c > @@ -206,7 +206,9 @@ static int chaoskey_probe(struct usb_interface *interface, > if (!dev->hwrng_registered) > usb_err(interface, "Unable to register with hwrng"); > > + usb_lock_device(udev); > usb_enable_autosuspend(udev); > + usb_unlock_device(udev); Not needed (indeed, actively harmful). When this code runs it already holds the device lock, because it is part of a probe routine. Alan Stern