Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3311636imu; Sun, 11 Nov 2018 12:07:49 -0800 (PST) X-Google-Smtp-Source: AJdET5eONqZSNKlivDvk8ycVzJJP83fuY7RFUldY21+reN1Ftn1Vu6sk1gRHDqqXSM36iWm22LFF X-Received: by 2002:a17:902:a9:: with SMTP id a38-v6mr17412717pla.7.1541966869758; Sun, 11 Nov 2018 12:07:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541966869; cv=none; d=google.com; s=arc-20160816; b=TdRqNl5b8mly0CuBUEVB594b21r6uo6inT+pEuC1UvlVU00HUpGlcWLoGA/8DtZxE1 x7jTkUPTpLzwaoDUbyzEytV7PTTwOAvA3QiRmqYiGb43TXch9W12wFsZh1V5v5Cxs5p/ PoD+kvkYwgzOVfRO/4a/nM/ObVGi7r3dQde0dyJ+DK7ihjAFR01HWavigsPQ7wJ9QBBJ /v/vuuDwwL+xOUbu5eOjVcXOX7g8SoK38I3BFZQcy+gZqWXiYK0xP0JACj6PQ17nhlOA Fjn9XnkHnuYbT9g1LqcHCW0rx2Fiq0zO+orBhmhXfZyg0cvBm+3Xbp5c1No2DvuMt5Dx NHLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=kcc6WVLUZhXsRzRrB41FX2r2bS+hpY8MnQYDiC/Cc6s=; b=0q8CdluTs+Uh3UXdVV8fwY3t5NYw707ILxmIWBriNYDhdzLfyHv1yYCPEsMWEqRATI 0wypeSsCBHz9aAE738QTOr2B3vuECgTNANE32MLxv3lcVyKblBxDkFqb7kQNW5f8s8BJ PCELDF6ZR+nw/L5yvUEbjPrhHeKFWtYel3zoOQp451Xr3mBJi0clRQ0jZF1nvd+g4LAr f147WiQSmMk8JbKG+RQQBFpUkRoPccT1z+GdMUZ5rm/o4CyshtCbPmFDUHng4qigCGF7 vzKbC6xrmtc5+ddX317jbZC/8dEzyx74tp4HZVLJ3nC6ne6SjZAFUkn/xKtZfAihNOZ8 8z2w== 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 u23si14445737pgb.66.2018.11.11.12.07.34; Sun, 11 Nov 2018 12:07:49 -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 S1731426AbeKLF4f (ORCPT + 99 others); Mon, 12 Nov 2018 00:56:35 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:52072 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727449AbeKLF4e (ORCPT ); Mon, 12 Nov 2018 00:56:34 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvss-0000l7-4z; Sun, 11 Nov 2018 19:59:02 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsV-0001g7-H5; Sun, 11 Nov 2018 19:58:39 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Dan Carpenter" , "Johan Hovold" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 229/366] USB: serial: ch341: fix type promotion bug in ch341_control_in() In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Dan Carpenter commit e33eab9ded328ccc14308afa51b5be7cbe78d30b upstream. The "r" variable is an int and "bufsize" is an unsigned int so the comparison is type promoted to unsigned. If usb_control_msg() returns a negative that is treated as a high positive value and the error handling doesn't work. Fixes: 2d5a9c72d0c4 ("USB: serial: ch341: fix control-message error handling") Signed-off-by: Dan Carpenter Signed-off-by: Johan Hovold Signed-off-by: Ben Hutchings --- drivers/usb/serial/ch341.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/usb/serial/ch341.c +++ b/drivers/usb/serial/ch341.c @@ -131,7 +131,7 @@ static int ch341_control_in(struct usb_d r = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), request, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, value, index, buf, bufsize, DEFAULT_TIMEOUT); - if (r < bufsize) { + if (r < (int)bufsize) { if (r >= 0) { dev_err(&dev->dev, "short control message received (%d < %u)\n",