Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1721692ybk; Thu, 21 May 2020 13:39:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTyQvcCTbnFDiqzWptfy+EhYO6RWQa8z5UM95gmU2zAJeKCDgWc7W7sF8Dq/kUf7EcWS9R X-Received: by 2002:a05:6402:1bd9:: with SMTP id ch25mr449243edb.15.1590093588404; Thu, 21 May 2020 13:39:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590093588; cv=none; d=google.com; s=arc-20160816; b=HlXwR0kgbRC8Sb9fZnXfIN9mQpRshZh8DCPOHYx+Rt0fzFSi2X8NroboRHtU6e5y8x fWIeAKWFHJqPQWuEPLoeTMOFwSglcEtyh0ducRiCTecSQYCKbiAHRqF/olBom5KNw/Nw toutmaJgB2E7MD+pbqYY6T2P4kYSp9mVbOFPJT9ptyOlYJfBPuIF8faBJCoueJNY/CHh qJdNlwYLUmjQ/eiwgWQUERlqY5D1Y6b8FwLCbH9koYJwH8/Kj92QGE4GhxDAFBm1uJ2r N26trE8SgCPRZSTpgL7g1v5qt2f88IkuAKbzjYJrSzrk6gJdecGs3pZBDCyK2x82rUud i0Ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=9xP5vfoBO+4BJ4jvW3objaO6eouH59qs+QM52qR8o3M=; b=SZ9SEtIIWFzjyLkKx/n9Yg5Z/aT7wx+PV69p1kWZKQizE4KYr0QdoLsoYQFHFHepA/ biwnAStYZ0ai2NdfKJrN+M8OLlUxr/IRGjVrF7Pl+59AP38hoDRmyrKs/n4dc5tT2rDc p3yJOF1kVVPrv4xslerHJV+Wp83++7iH4RJoabu1+G48Mkk19ikdiHKn5Lh4kRy6yOr2 gjO+4VATBSxzp6+bTwSQwAbnw1O+FbDTTXf3rWOwEwQ6tWWEWaTC1/1trveM8zW36T4q jBkYsW9aEyDVauzjdxtegEzCgTxNNnDHNJD1v7WVes7rm1aVPAiv1kVCo5XII/sbqxNJ I8dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="b/hWi2PD"; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r15si3712268ejb.735.2020.05.21.13.39.25; Thu, 21 May 2020 13:39:48 -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; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="b/hWi2PD"; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729993AbgEUUhb (ORCPT + 99 others); Thu, 21 May 2020 16:37:31 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:48008 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726814AbgEUUhb (ORCPT ); Thu, 21 May 2020 16:37:31 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 04LKbSm1048692; Thu, 21 May 2020 15:37:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1590093448; bh=9xP5vfoBO+4BJ4jvW3objaO6eouH59qs+QM52qR8o3M=; h=Date:From:To:CC:Subject:References:In-Reply-To; b=b/hWi2PDFf0VSW2yJawZ9W2H2iAfh74UixmbprqMb+4CTu8dY2EItfrV99ePrzmQ0 jjNwTxIHNdFt4t/UElwxtNZUE29emuVrZoyBtbhEG38MoxAvRHKeq+9o5AikPB+I/b W7BtoKvEPU6yNq2Ly0UldLf0/P1lnMT0t4p7f410= Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 04LKbSLW089527 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 21 May 2020 15:37:28 -0500 Received: from DLEE109.ent.ti.com (157.170.170.41) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Thu, 21 May 2020 15:37:28 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Thu, 21 May 2020 15:37:28 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 04LKbSOO098116; Thu, 21 May 2020 15:37:28 -0500 Date: Thu, 21 May 2020 15:37:28 -0500 From: Bin Liu To: Dinghao Liu CC: , Greg Kroah-Hartman , , Subject: Re: [PATCH] usb: musb: Fix runtime PM imbalance on error Message-ID: <20200521203728.GB25575@iaqt7> Mail-Followup-To: Bin Liu , Dinghao Liu , kjlu@umn.edu, Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org References: <20200521073547.18828-1-dinghao.liu@zju.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20200521073547.18828-1-dinghao.liu@zju.edu.cn> User-Agent: Mutt/1.9.4 (2018-02-28) X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Thu, May 21, 2020 at 03:35:47PM +0800, Dinghao Liu wrote: > When copy_from_user() returns an error code, a pairing > runtime PM usage counter decrement is needed to keep > the counter balanced. > > Signed-off-by: Dinghao Liu > --- > drivers/usb/musb/musb_debugfs.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/musb/musb_debugfs.c b/drivers/usb/musb/musb_debugfs.c > index 7b6281ab62ed..837c38a5e4ef 100644 > --- a/drivers/usb/musb/musb_debugfs.c > +++ b/drivers/usb/musb/musb_debugfs.c > @@ -178,8 +178,11 @@ static ssize_t musb_test_mode_write(struct file *file, > > memset(buf, 0x00, sizeof(buf)); > > - if (copy_from_user(buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) > + if (copy_from_user(buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) { > + pm_runtime_mark_last_busy(musb->controller); > + pm_runtime_put_autosuspend(musb->controller); > return -EFAULT; > + } Thanks for catching the bug. Can you please instead move these lines to the beginning of this function so that pm_runtime_get_sync() is not called if copy_from_user() failed? -Bin.