From patchwork Tue Feb 19 15:19:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin King X-Patchwork-Id: 10820019 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 31050180E for ; Tue, 19 Feb 2019 15:19:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F41D2A8B0 for ; Tue, 19 Feb 2019 15:19:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1DAED2C7DA; Tue, 19 Feb 2019 15:19:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 998FD2A8B0 for ; Tue, 19 Feb 2019 15:19:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728201AbfBSPTV (ORCPT ); Tue, 19 Feb 2019 10:19:21 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:56697 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726232AbfBSPTV (ORCPT ); Tue, 19 Feb 2019 10:19:21 -0500 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1gw7B1-00018G-9U; Tue, 19 Feb 2019 15:19:19 +0000 From: Colin King To: Heikki Krogerus , Greg Kroah-Hartman , linux-usb@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] usb: typec: mux: fix an unsigned less than zero check Date: Tue, 19 Feb 2019 15:19:18 +0000 Message-Id: <20190219151918.13114-1-colin.king@canonical.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Colin Ian King The checks of a negative nval indicating an error an never be true as nval is currently a size_t which is of course unsigned and hence never less than zero. Fix this by making nval an int. Detected by CoverityScan, CID#1476863 ("Unsigned compared against 0) and CID#1476948 ("Loop bound") Fixes: 96a6d031ca99 ("usb: typec: mux: Find the muxes by also matching against the device node") Signed-off-by: Colin Ian King --- drivers/usb/typec/mux.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c index b94e2920eb38..64d2ed3fecb8 100644 --- a/drivers/usb/typec/mux.c +++ b/drivers/usb/typec/mux.c @@ -126,10 +126,9 @@ static void *typec_mux_match(struct device_connection *con, int ep, void *data) { const struct typec_altmode_desc *desc = data; struct typec_mux *mux; - size_t nval; bool match; u16 *val; - int i; + int i, nval; if (!con->fwnode) { list_for_each_entry(mux, &mux_list, entry)