Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756820AbcK2NKG (ORCPT ); Tue, 29 Nov 2016 08:10:06 -0500 Received: from m50-133.163.com ([123.125.50.133]:51687 "EHLO m50-133.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752161AbcK2NJ4 (ORCPT ); Tue, 29 Nov 2016 08:09:56 -0500 From: Pan Bian To: Johan Hovold , linux-usb@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Pan Bian Subject: [PATCH 1/1] usb: abort on exception path Date: Tue, 29 Nov 2016 20:53:35 +0800 Message-Id: <1480424015-24930-1-git-send-email-bianpan2016@163.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: DdGowAB3v5tRej1YH828IA--.47092S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrKF1xGrW8tr4xtr48CF4xtFb_yoWfuwc_Cr 9rWan7ur10qFZ8J348Ca4rtrWfKF1DX395JFyqqFZxtF9Fqa9xAr4vvrZ8ur4kJrykJFyD GwnxGryI9r1rJjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUeXJ53UUUUU== X-Originating-IP: [222.131.246.88] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/1tbiQBUxclSIRPV5owAAsh Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 916 Lines: 26 Function klsi_105_open() calls usb_control_msg() and checks its return value. When the return value is unexpected, it only assigns the error code to the return variable retval, but does not terminate the exception path. This patch fixes the bug by inserting "goto exit;" when the call to usb_control_msg() fails. Signed-off-by: Pan Bian --- drivers/usb/serial/kl5kusb105.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c index fc5d3a7..068919f 100644 --- a/drivers/usb/serial/kl5kusb105.c +++ b/drivers/usb/serial/kl5kusb105.c @@ -311,6 +311,7 @@ static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port) if (rc < 0) { dev_err(&port->dev, "Enabling read failed (error = %d)\n", rc); retval = rc; + goto exit; } else dev_dbg(&port->dev, "%s - enabled reading\n", __func__); -- 1.9.1