Return-Path: Received: from mail-lf0-f67.google.com ([209.85.215.67]:36754 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750873AbdALOGI (ORCPT ); Thu, 12 Jan 2017 09:06:08 -0500 From: Johan Hovold To: linux-usb@vger.kernel.org Cc: Johan Hovold , stable Subject: [PATCH 01/15] USB: serial: ark3116: fix register-accessor error handling Date: Thu, 12 Jan 2017 14:56:09 +0100 Message-Id: <20170112135623.28732-2-johan@kernel.org> In-Reply-To: <20170112135623.28732-1-johan@kernel.org> References: <20170112135623.28732-1-johan@kernel.org> Sender: stable-owner@vger.kernel.org List-ID: The current implementation failed to detect short transfers, something which could lead to bits of the uninitialised heap transfer buffer leaking to user space. Fixes: 149fc791a452 ("USB: ark3116: Setup some basic infrastructure for new ark3116 driver.") Fixes: f4c1e8d597d1 ("USB: ark3116: Make existing functions 16450-aware and add close and release functions.") Cc: stable Signed-off-by: Johan Hovold --- drivers/usb/serial/ark3116.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c index 1532cde8a437..7812052dc700 100644 --- a/drivers/usb/serial/ark3116.c +++ b/drivers/usb/serial/ark3116.c @@ -99,10 +99,17 @@ static int ark3116_read_reg(struct usb_serial *serial, usb_rcvctrlpipe(serial->dev, 0), 0xfe, 0xc0, 0, reg, buf, 1, ARK_TIMEOUT); - if (result < 0) + if (result < 1) { + dev_err(&serial->interface->dev, + "failed to read register %u: %d\n", + reg, result); + if (result >= 0) + result = -EIO; + return result; - else - return buf[0]; + } + + return buf[0]; } static inline int calc_divisor(int bps) -- 2.10.2