Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6023001ybc; Wed, 27 Nov 2019 13:34:22 -0800 (PST) X-Google-Smtp-Source: APXvYqxbVK4zZs41VfbqLzvjYD8nBtpoK5BRsRE/WgRrU2Lm5jhxBjJDk7EJOgLeltjW8c9sFGso X-Received: by 2002:a05:6402:13d4:: with SMTP id a20mr34726475edx.105.1574890462848; Wed, 27 Nov 2019 13:34:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574890462; cv=none; d=google.com; s=arc-20160816; b=pbvisMvqI1rLmIImpka/nBjvYK5BCnx6upKLXpTSO2KshWfvIrYnxl+BLS1WiT4/Px Fw+p9586R6EHwLUoJ4vermTJDLa2M6sSeEsN00u3APsnVxKg5xYCcvB6eG8wR/xsUw1S q/v/FDvrLEqm7izhYZjc8QF75uKid3j4uNqibeSW6qehJpzQBrJRNAOFbi9XHeatpWXZ PE0yGVhi/j5byX1NjKtLlTs7ZeQrITX2OY57v8lWi9wQxvz2tSNlEwe/NUNYwxE47QKU lf/dlrrnPQ//0cqRcuAAAvLgUA8tZRnHxirt4/ofaHe+VTv1IIbzcYo7xspDkK6Eem8e 9x6Q== 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=UyEc7rXy2/LQE5qdIWu0o+YyYmYJwcxinWXQ6wDrf8E=; b=ihPctjG+/hZ2SL6FRCwc6Il4H3x7Za70SY12AdRmu6Z0QaBx80/KM6XcxSUx8Ty1is mVMHsETpGQBvE0ehzgKyMQcwhbDbk9K8R5h3TVK1STYEdVVr4qeW9BClKQX3m0IKMOqJ ZSzGyxSS47R5KUkxoI/TpqsEXagSjEcbtTPvprWiEbaGQjiymPshxp6ESatYlUVDi7Qn 1iI+QN7DIElj7G722weUbcudnz6i+Cn2boPeh2ezMoe7pGFHRxSa2Hhc+4PesuH5HP6f QoSP3nkx65e6XoGtCPfMEPH916tK2dOyeSK+IHmIVhka9KwMxgwu2dllEw85gPOWMep0 j3FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mAcefy4u; 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 p8si10549691edq.55.2019.11.27.13.33.59; Wed, 27 Nov 2019 13:34:22 -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; dkim=pass header.i=@kernel.org header.s=default header.b=mAcefy4u; 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 S1730205AbfK0UyY (ORCPT + 99 others); Wed, 27 Nov 2019 15:54:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:44222 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729004AbfK0UyU (ORCPT ); Wed, 27 Nov 2019 15:54:20 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 6BC1A2154A; Wed, 27 Nov 2019 20:54:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888059; bh=FzCglVxcSpKyCaxsRhGAWDD0lVXiYxk8tTZGIPr44Ww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mAcefy4u9WatpyUXp7Xh8umeHUSD6+irkp5NRIRBANjqCz3p4n2PNg2Sj+Xj0lE0Q C8OKY9zcY1nUG6vwWNCEHisSx+6wczgM2M4VFTqNsYVmzMBujcord5NtvTxVz0rSuU ccsuvKFcLChJbw5Q54Iit48MVR8ka1wXZSEyQmJE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oliver Neukum Subject: [PATCH 4.14 200/211] USB: chaoskey: fix error case of a timeout Date: Wed, 27 Nov 2019 21:32:13 +0100 Message-Id: <20191127203112.492188901@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203049.431810767@linuxfoundation.org> References: <20191127203049.431810767@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: Oliver Neukum commit 92aa5986f4f7b5a8bf282ca0f50967f4326559f5 upstream. In case of a timeout or if a signal aborts a read communication with the device needs to be ended lest we overwrite an active URB the next time we do IO to the device, as the URB may still be active. Signed-off-by: Oliver Neukum Cc: stable Link: https://lore.kernel.org/r/20191107142856.16774-1-oneukum@suse.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/chaoskey.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) --- a/drivers/usb/misc/chaoskey.c +++ b/drivers/usb/misc/chaoskey.c @@ -396,13 +396,17 @@ static int _chaoskey_fill(struct chaoske !dev->reading, (started ? NAK_TIMEOUT : ALEA_FIRST_TIMEOUT) ); - if (result < 0) + if (result < 0) { + usb_kill_urb(dev->urb); goto out; + } - if (result == 0) + if (result == 0) { result = -ETIMEDOUT; - else + usb_kill_urb(dev->urb); + } else { result = dev->valid; + } out: /* Let the device go back to sleep eventually */ usb_autopm_put_interface(dev->interface); @@ -538,7 +542,21 @@ static int chaoskey_suspend(struct usb_i static int chaoskey_resume(struct usb_interface *interface) { + struct chaoskey *dev; + struct usb_device *udev = interface_to_usbdev(interface); + usb_dbg(interface, "resume"); + dev = usb_get_intfdata(interface); + + /* + * We may have lost power. + * In that case the device that needs a long time + * for the first requests needs an extended timeout + * again + */ + if (le16_to_cpu(udev->descriptor.idVendor) == ALEA_VENDOR_ID) + dev->reads_started = false; + return 0; } #else