From patchwork Thu May 14 08:05:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Macpaul Lin X-Patchwork-Id: 11548219 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0FD1714C0 for ; Thu, 14 May 2020 08:05:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F021F206BE for ; Thu, 14 May 2020 08:05:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="fkyRCUsu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726059AbgENIFJ (ORCPT ); Thu, 14 May 2020 04:05:09 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:26663 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725935AbgENIFJ (ORCPT ); Thu, 14 May 2020 04:05:09 -0400 X-UUID: 4fb1093cbcec4f18b37bac5a7521f79b-20200514 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=mrYggCzs9Es3fAAe5f56aAmDrVDKZRIo+656NWVNAmE=; b=fkyRCUsuWECnwmFc3f1cZXB24o/Glfzc2EQM5fLKOFMBPDIK7BEpRcyM51QiQdYGDlwyCu8ufO+euJxRm6XqxY4Tdfa0UAbehr5MPvGAjBbSTuEbh6x/h6T9MlrGz4bNaohU7K9pW4WKg3suI9K2fx3fHwhOA2Ur1pi+Kv2jq8A=; X-UUID: 4fb1093cbcec4f18b37bac5a7521f79b-20200514 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 930876128; Thu, 14 May 2020 16:05:05 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs08n1.mediatek.inc (172.21.101.55) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 14 May 2020 16:05:01 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 14 May 2020 16:05:01 +0800 From: Macpaul Lin To: Felipe Balbi , Greg Kroah-Hartman , Matthias Brugger , =?utf-8?b?TWljaGHFgiBNaXJvc8WC?= =?utf-8?b?YXc=?= , Sergey Organov , Macpaul Lin , , , , CC: Mediatek WSD Upstream , Macpaul Lin , Stan Lu Subject: [PATCH] usb: gadget: u_serial: fix coverity warning: negative index at array Date: Thu, 14 May 2020 16:05:00 +0800 Message-ID: <1589443500-3990-1-git-send-email-macpaul.lin@mediatek.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-MTK: N Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org This issue has been reported by coverity scanner. Replace "int portnum" by "unsigned int", this void negative index at array. Signed-off-by: Stan Lu Signed-off-by: Macpaul Lin --- drivers/usb/gadget/function/u_serial.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c index 8167d37..53951f2 100644 --- a/drivers/usb/gadget/function/u_serial.c +++ b/drivers/usb/gadget/function/u_serial.c @@ -587,7 +587,7 @@ static int gs_start_io(struct gs_port *port) */ static int gs_open(struct tty_struct *tty, struct file *file) { - int port_num = tty->index; + unsigned int port_num = tty->index; struct gs_port *port; int status = 0; @@ -1211,7 +1211,7 @@ int gserial_alloc_line_no_console(unsigned char *line_num) struct gs_port *port; struct device *tty_dev; int ret; - int port_num; + unsigned int port_num; coding.dwDTERate = cpu_to_le32(9600); coding.bCharFormat = 8;