Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp268901imu; Mon, 10 Dec 2018 21:29:02 -0800 (PST) X-Google-Smtp-Source: AFSGD/UZLBvYeo39htphPDK6BYQCL4c3lPiuf8Mqpyx7GANmcwgS/zHrQkhTy4ODXLIQSLOL1IiE X-Received: by 2002:a63:da45:: with SMTP id l5mr13567939pgj.111.1544506142466; Mon, 10 Dec 2018 21:29:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544506142; cv=none; d=google.com; s=arc-20160816; b=PVZayqrIMMB8D0QH+WHqFrNBJvY90SmouS9mVwbZh270hncpZy6Kygybso06F4uRdB uZuZOR8ZG0el2VUqyCkjUmB5itKdGiMxpD7VcVPAuxlc6/r0TOJJqISBAdFfNw3eMZVG dAnH5EXabwuNToEWf5b1pkI3prpjTzPhQF9ywWEVBZLuKlQDwcjefCk0gYBsy+lF49Zi aL3LEXaeh/WPV3EEe1DjtsuxG65IRUujthTe930G5WS3mBetD2mZuIcuF78P/H66DRoe Tjyb2Ilm3O8ZO/mtB6HMSZwWUV9LLjb/FkujGWnO9hanOMyzoPPrYAvCHH67YBJgyNCy cimA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=j/txMKta3vGwi9/6kVsWKsbsFxVmcgITypyjkrv387Y=; b=CpxBEHduGpjJFpEq5w9iLO0cMCeaYGxt942aGI5SxD1ErFZym+KbSW0KBoamZTMfCt v3SDI09lWpYy2ZaTEibUiGLdlQUMwxlbImRoegCVJWytYR70jeENpBk8SEvd6Kb2PbWI rRXT/GYMv1hX2HH3kHtNsw5GHPC6elcooxYA8ki0ykLzmu26zlRUsdzoYWHOycRsH/2Z 6cDU6KUIRrykUV5ZJCCeaAmjFBb1vYxGLBbgZaJl49Yu2UocZtksgiPcAKpmDGXoVKwq XIiNhr4yHI1VKymptEJWP0+Z0jeH4n3+xzK24d5wFluH1+kHPGLbzxaC+dnYUSDwe+0N gAxw== 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 90si11992527plb.17.2018.12.10.21.28.47; Mon, 10 Dec 2018 21:29:02 -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 S1729834AbeLKDOR (ORCPT + 99 others); Mon, 10 Dec 2018 22:14:17 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:42307 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729765AbeLKDOR (ORCPT ); Mon, 10 Dec 2018 22:14:17 -0500 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 0D4BBF318FD0C; Tue, 11 Dec 2018 11:14:13 +0800 (CST) Received: from localhost (10.177.31.96) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.408.0; Tue, 11 Dec 2018 11:14:07 +0800 From: YueHaibing To: , , , CC: , , , YueHaibing Subject: [PATCH net-next] ieee802154: ca8210: fix possible u8 overflow in ca8210_rx_done Date: Tue, 11 Dec 2018 11:13:39 +0800 Message-ID: <20181211031339.21048-1-yuehaibing@huawei.com> X-Mailer: git-send-email 2.10.2.windows.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.177.31.96] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org gcc warning this: drivers/net/ieee802154/ca8210.c:730:10: warning: comparison is always false due to limited range of data type [-Wtype-limits] 'len' is u8 type, we get it from buf[1] adding 2, which can overflow. This patch change the type of 'len' to unsigned int to avoid this,also fix the gcc warning. Fixes: ded845a781a5 ("ieee802154: Add CA8210 IEEE 802.15.4 device driver") Signed-off-by: YueHaibing --- drivers/net/ieee802154/ca8210.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c index 0ff5a40..b2ff903 100644 --- a/drivers/net/ieee802154/ca8210.c +++ b/drivers/net/ieee802154/ca8210.c @@ -721,7 +721,7 @@ static void ca8210_mlme_reset_worker(struct work_struct *work) static void ca8210_rx_done(struct cas_control *cas_ctl) { u8 *buf; - u8 len; + unsigned int len; struct work_priv_container *mlme_reset_wpc; struct ca8210_priv *priv = cas_ctl->priv; @@ -730,7 +730,7 @@ static void ca8210_rx_done(struct cas_control *cas_ctl) if (len > CA8210_SPI_BUF_SIZE) { dev_crit( &priv->spi->dev, - "Received packet len (%d) erroneously long\n", + "Received packet len (%u) erroneously long\n", len ); goto finish; -- 2.7.0