Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1193807ybk; Thu, 21 May 2020 00:39:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPdKqI5uK5XIF9vypqx4Isxm4kSjlyj+nuPNXcyja59jsREMHBkPEPnDob/y/X+HKNDqML X-Received: by 2002:a50:8b42:: with SMTP id l60mr6628197edl.55.1590046797070; Thu, 21 May 2020 00:39:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590046797; cv=none; d=google.com; s=arc-20160816; b=kXeXpKg4tDPuxiTtOXiqp7w8Xo/JsmN6gqJMwlSxGm8O1vyH8zkXzzXUmMEGsAKjY3 /DUMVM9OoiVUS3f90rLjLuwKt43WUiYG8a2nFupIbo+lR64dKQ2yYbItHYWfiQYiOSBF l67MkzfE9Uz93LwVa2eESF5ctUXqqnhV6FVloScSLR5yepLjCGpz/BbrMS3d3GNQMGd8 0q9aexr7n4ZvxvsLMCinyi3D4qaVe/evf5eAambzgiyA00eDi7vz4XzYR0ZZY6OsYBiD GuRvJUo8gfn5c8qOdF0KJaA5Ko5iXKbV6/4hq9eCDh2d9YD73M7yNg2Ox7+miTZtL7lj OkcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=FSJt/+H88mhhpP8pGo7Q39rt6FsDF7EnrtUq2u7wE7I=; b=whaymHDyBjbXXugS5K7c/U1dfq5Ipbz4MQTrjK48DPA/mXjVj6JI6T/JVHvbSKB3fs 9Z0lVBg+5Gwok8DqjthmIlhMSaFN4gl2hiqRJ9yg6rSJq12H8DCrMyxz6UTEBXB/tDcS XjoUBkMPtr1OdwhlUZmPW7LqHReDmIvMXLhxtfLfTxiWfgRHTfEutBINa1BFxE4euxCL QFMoQAgJvH/2lfTXeiRl00coODJ+cWJAdU1vWdHW567VYhQuIcO+H8zThO39aVvqkYdJ XqNciaVm7KDqc1qbuiOWfgXKj+46utkcYGWhZ4tYDWDBq9S6gpBBUnykPlFjj9XVw65r Jnmw== 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 t22si2840530edi.249.2020.05.21.00.39.33; Thu, 21 May 2020 00:39:57 -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 S1728437AbgEUHgB (ORCPT + 99 others); Thu, 21 May 2020 03:36:01 -0400 Received: from mail.zju.edu.cn ([61.164.42.155]:43438 "EHLO zju.edu.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728245AbgEUHgA (ORCPT ); Thu, 21 May 2020 03:36:00 -0400 Received: from localhost.localdomain (unknown [222.205.77.158]) by mail-app3 (Coremail) with SMTP id cC_KCgDX34tUL8ZeXfHmAA--.2795S4; Thu, 21 May 2020 15:35:52 +0800 (CST) From: Dinghao Liu To: dinghao.liu@zju.edu.cn, kjlu@umn.edu Cc: Bin Liu , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] usb: musb: Fix runtime PM imbalance on error Date: Thu, 21 May 2020 15:35:47 +0800 Message-Id: <20200521073547.18828-1-dinghao.liu@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: cC_KCgDX34tUL8ZeXfHmAA--.2795S4 X-Coremail-Antispam: 1UD129KBjvdXoWruFWUAFy7ArWrZFyfWF1xKrg_yoWDAFgEkr nxuF18Wr4q9Fyjy342yw15ZrWFga95Xr9rWFnYka43AayYqFn5Zry0qryDZwsxtF17ur1D A34kZrn7GF48CjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbIkFc2x0x2IEx4CE42xK8VAvwI8IcIk0rVWrJVCq3wAFIxvE14AK wVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK021l84ACjcxK6xIIjxv20x vE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26F4UJVW0owA2z4x0Y4vEx4A2 jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52 x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUGVWU XwAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI4 8JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY02Avz4vE14v_GF4l42xK82IYc2Ij64vIr41l 42xK82IY6x8ErcxFaVAv8VW8uw4UJr1UMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I 8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWU twCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x 0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Wr1j6rW3Jr1lIxAIcVC2z280aVAF wI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf 9x0JU9o7NUUUUU= X-CM-SenderInfo: qrrzjiaqtzq6lmxovvfxof0/1tbiAgEHBlZdtOPItAAHsl Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; + } if (strstarts(buf, "force host full-speed")) test = MUSB_TEST_FORCE_HOST | MUSB_TEST_FORCE_FS; -- 2.17.1