Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1396725ybp; Thu, 17 Oct 2019 12:10:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqxOkINhs1nTKbWIIVY82RFP20abozWXQHw0FVwZUCf/6Tg3+WVh69f2aPNWDfMRzRe+kivN X-Received: by 2002:a17:906:28ce:: with SMTP id p14mr5121342ejd.164.1571339420568; Thu, 17 Oct 2019 12:10:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571339420; cv=none; d=google.com; s=arc-20160816; b=IXvc6E588q7kQ1SOPYhorcxUsh+CMwFWCkMCoqFy/W4ZaCeb026wWy5ydXGrDJPtVH 1gewJflfoDpzj2YFLU04zufuZf8iKBq8ydcnQM0MqJ/FwnYqK6AmuFKip/Ty4u/gVzgU 9MPz/QEhnbBpQLp0/XMEK3ypQ5yh+/Nb+aQIchCDQ2aZFunlm05EcBzY26fFO/xpa6c7 l3gI6GuKev5eb3NW2d9WFVeAK0q4HvXJCfxfX99qNpxi7673HtWj+G9ExChZ8P/4f/th KcXOZ3JlSXhHNJ3AUpCDbj0MuY6uWq3h2FmsRD3F6kNasxmURC5Gy/WTdT+8vvdnOVth AGPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3TXhDKPsWq/J8UQQpxXgdxprhxCvn46Cq6Ztjn7d+Uw=; b=siqqdwxtSkyDXGPA8NZN84jy/4FPl9FH/f6UfSTjHkRelkvoC1slpdZGh3K42YClTH NshRg8XGHjbW5ieBKUMZIIfd+iB/FGdSfEGaAB/VVel/ppyS2+lZQ979gNfhs3/hYzmp fbcLa46Xorl4ZrfN0pEkiLW+dlsLs6/vCysuZxfVXDH+9O7ulql9gRGxjjYRiL8ccHCW Fgx2bhgnpVlVbap7sii6F8ePm0VXiLY1Cuc0sQaYaAcVq+MWxWfOd8pbfnrlc1qeqHjE Y0t7OgqauYeeBf3QkXe8w84p5RT3c5W7NuqlqEKDalx+4gxQ5Iw7ln2GeEWFFfT9TYmR yV2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MfQcNc04; 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 w10si2077896edv.21.2019.10.17.12.09.56; Thu, 17 Oct 2019 12:10:20 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=MfQcNc04; 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 S2439272AbfJPWMp (ORCPT + 99 others); Wed, 16 Oct 2019 18:12:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:47592 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404008AbfJPV4M (ORCPT ); Wed, 16 Oct 2019 17:56:12 -0400 Received: from localhost (unknown [192.55.54.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0E0D321925; Wed, 16 Oct 2019 21:56:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571262971; bh=oxkWNxzXo5Rq8VQmI1FVdzmCWqOC2IDSLeRr5WFXm6o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MfQcNc04WSegiu0Yd7nvGuWA7U5YeNtaVnAQdWn8Tvkvs2TESk7gzNowkKxq+0/bB aIM2APZsz3YCvyKpRoUrzsi+JjRWCClRb143/KcAvVWprbGdquf3t1K3Hijg8B1nnm mqRrn3ek3boQZTnP8jIHWPvA3nssfWwFQlf0fFVE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johan Hovold Subject: [PATCH 4.14 06/65] USB: usb-skeleton: fix runtime PM after driver unbind Date: Wed, 16 Oct 2019 14:50:20 -0700 Message-Id: <20191016214800.020396108@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191016214756.457746573@linuxfoundation.org> References: <20191016214756.457746573@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johan Hovold commit 5c290a5e42c3387e82de86965784d30e6c5270fd upstream. Since commit c2b71462d294 ("USB: core: Fix bug caused by duplicate interface PM usage counter") USB drivers must always balance their runtime PM gets and puts, including when the driver has already been unbound from the interface. Leaving the interface with a positive PM usage counter would prevent a later bound driver from suspending the device. Fixes: c2b71462d294 ("USB: core: Fix bug caused by duplicate interface PM usage counter") Cc: stable Signed-off-by: Johan Hovold Link: https://lore.kernel.org/r/20191001084908.2003-2-johan@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/usb-skeleton.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) --- a/drivers/usb/usb-skeleton.c +++ b/drivers/usb/usb-skeleton.c @@ -75,6 +75,7 @@ static void skel_delete(struct kref *kre struct usb_skel *dev = to_skel_dev(kref); usb_free_urb(dev->bulk_in_urb); + usb_put_intf(dev->interface); usb_put_dev(dev->udev); kfree(dev->bulk_in_buffer); kfree(dev); @@ -126,10 +127,7 @@ static int skel_release(struct inode *in return -ENODEV; /* allow the device to be autosuspended */ - mutex_lock(&dev->io_mutex); - if (dev->interface) - usb_autopm_put_interface(dev->interface); - mutex_unlock(&dev->io_mutex); + usb_autopm_put_interface(dev->interface); /* decrement the count on our device */ kref_put(&dev->kref, skel_delete); @@ -507,7 +505,7 @@ static int skel_probe(struct usb_interfa init_waitqueue_head(&dev->bulk_in_wait); dev->udev = usb_get_dev(interface_to_usbdev(interface)); - dev->interface = interface; + dev->interface = usb_get_intf(interface); /* set up the endpoint information */ /* use only the first bulk-in and bulk-out endpoints */