Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4024629ybv; Tue, 25 Feb 2020 11:40:36 -0800 (PST) X-Google-Smtp-Source: APXvYqynDVLuZGiimFW+PaaOBc71cVRzkijeZgZwb4UeocNgGraWv3lc3DVuU9qBmHnuROlFjveV X-Received: by 2002:aca:f20b:: with SMTP id q11mr406281oih.78.1582659635901; Tue, 25 Feb 2020 11:40:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582659635; cv=none; d=google.com; s=arc-20160816; b=Lh3NWAVXBjMrBz9S/ZeNNlYWJGcc0kkUr5ybAv5/X1n9TtN2UCwSH2bWtx31oJbu3O K+a+pyOe+R9+BXbJBDaqv9t6DkGFwwiu2EWksrjkO2Fj88ikQVkQx9Hd/J+ZbIOdJno6 3Ul7wLU/oU4OUvqKWr8csBaXu5E/Iy5O7dm0FLYdPXGogmGIueIKrLhbvrr1uRTJ51b3 NE0xVMZebrORyTfS08YWdykM07gXoKJbO90zwhCH0YGH7V+KPfrra2wYOZ6IM4qc9RnX buwojD14O/8JHiTKxP6USZDmnEselZZVKUBde43QlgHos0jfeg/UnfJ31LkQENG/glyp B+WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date; bh=qRR/mmmgmH6P7NU1btduQrgWzU9ICwU7DC6YUgh4/5E=; b=Ri9tnfpPcR/LVm36WCeLVczk5X+QKVkx0Jx6miDN6JBvbwGx6LRjAOUk6CyJt9UL/u h1I4UYCKnnVMzcwmCVE8eeDkfyqUp5acBvo8TmnjV1nqoYRfyf88+i22dN7jwkssxFd5 aYAkrM5YoAnKk5Q/Ik0WaI2ZXrd9FBikbhJVP6DbXuvecNyRLyCi9AACcnUR2Xy1sd7A iLZE615MsGBqFfka3FPkTNhePWjGxUu9ICUmHHuPukwmoI1qv+T66E/TJ2lzSrOg1mCK vCiA+pIWFN0pI8oGKQnep7XUtn9mJj0I2Aid5798/4hQh+IlwJmziq7qk/yeMziM1RlD /y2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n1si73823oic.225.2020.02.25.11.40.23; Tue, 25 Feb 2020 11:40:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730602AbgBYTjY (ORCPT + 99 others); Tue, 25 Feb 2020 14:39:24 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:39258 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1728162AbgBYTjY (ORCPT ); Tue, 25 Feb 2020 14:39:24 -0500 Received: (qmail 5824 invoked by uid 2102); 25 Feb 2020 14:39:23 -0500 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 25 Feb 2020 14:39:23 -0500 Date: Tue, 25 Feb 2020 14:39:23 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Eugeniu Rosca cc: linux-usb@vger.kernel.org, , , Greg Kroah-Hartman , Thinh Nguyen , "Lee, Chiasheng" , Mathieu Malaterre , Kai-Heng Feng , Hardik Gajjar , , Eugeniu Rosca Subject: Re: [PATCH] usb: hub: Fix unhandled return value of usb_autopm_get_interface() In-Reply-To: <20200225191241.GA32410@lxhi-065.adit-jv.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 25 Feb 2020, Eugeniu Rosca wrote: > Hi Alan, > > Many thanks for the prompt review. > > On Tue, Feb 25, 2020 at 10:32:32AM -0500, Alan Stern wrote: > > On Tue, 25 Feb 2020, Eugeniu Rosca wrote: > > > + int r = usb_autopm_get_interface(intf); > > > + > > > + if (!r) > > > + hub->quirk_disable_autosuspend = 1; > > > + else > > > + dev_dbg(&intf->dev, "disable autosuspend err=%d\n", r); > > > } > > > > > > if (hub_configure(hub, &desc->endpoint[0].desc) >= 0) > > > > This change is not necessary, because the resume operation cannot fail > > at this point (interfaces are always powered-up during probe). > > Agreed to avoid unneeded complexity. > > > A better solution would be to call usb_autpm_get_interface_no_resume() > > instead. > > Pushed to https://lore.kernel.org/lkml/20200225183057.31953-1-erosca@de.adit-jv.com > > > > > On the other hand, the other places that call > > usb_autopm_get_interface() without checking should be audited. Some of > > them almost certainly need to be fixed. > > A quick 'git grep' outputs below list of auditable candidates [1]. > > With no relevant devices at hand, I would avoid touching these drivers, > since oftentimes even legitimate patches introduce regressions w/o > testing. > > If anybody volunteers with testing, I guess it should be quick to > either convert usb_autpm_get_interface to *_no_resume variant or > handle the return value in place in below instances. > > [1] (v5.6-rc3) git grep -En "[^=]\s+usb_autopm_get_interface\(" > drivers/input/touchscreen/usbtouchscreen.c:1788: usb_autopm_get_interface(intf); > drivers/media/usb/stkwebcam/stk-webcam.c:628: usb_autopm_get_interface(dev->interface); > drivers/net/usb/hso.c:1308: usb_autopm_get_interface(serial->parent->interface); > drivers/net/usb/r8152.c:5231: usb_autopm_get_interface(tp->intf); > sound/usb/usx2y/us122l.c:192: usb_autopm_get_interface(iface); Your regular expression isn't right because it doesn't match lines where the usb_autopm_get_interface() is preceded only by one whitespace character (i.e., a tab). It also will match lines where there are two space characters between the = sign and the function name. I think what you want is more like "(^|[^=[:space:]])\s*" at the start of the RE. A revised search finds line 997 in drivers/usb/core/hub.c and lines 216, 269 in drivers/usb/core/port.c. (I didn't try looking in any other directories.) AFAICT all three of these should check the return value, although a error message in the kernel log probably isn't needed. Do you want to fix those instances up also, maybe merging them in with the existing patch? Alan Stern