Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3202917pxb; Mon, 9 Nov 2020 05:30:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJyoFTyTQLR8F8Ae2R8f2vXfI5h2WzAGE16G+nTjWo/l9VeKPARViL8q9ncCgsJ/nFkUlXmP X-Received: by 2002:a17:906:5e45:: with SMTP id b5mr14774421eju.46.1604928650093; Mon, 09 Nov 2020 05:30:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604928650; cv=none; d=google.com; s=arc-20160816; b=GSToIzF4AhVUiMUWv8PhdWAAvFGGGbFs/HMoekqnmfuRj+jJ88SIt77pCYVMsb/0pP eyZ2GgtWuSY+xeXlzGxPaHe5cMMIleULx3G+tF6tdhgEH6DnlEszVC6/6o3tidB4EgUZ GTXUTZR31kIG9+aIqj5g4WTuViKu5xSFw6rNeLH7WRvh6uOI+i1RWOcPata7mGZg71vV bty39zJ44C6ODs/j3b56Oqp4o8+4US9OIZ7imw7cZo8bCGfvK/0I11QKL0U8wRMMxDNo Gw+pwUSir6U0Vc64wstXuJ8OC6UFwi8u0JxkcxkRfrO1HALul180vDXb0StTdZ0zuEl3 +f5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NeUjAIhjK3bvhZXjvLZ5s7uG6Yf4VY3nocn97tMuMSQ=; b=hmhk2JP4sVBAjMyfSLtgrr/3DyXj8RLW6y4Odw36KKX1u/ldHzPdFd6dzOWadvcL4v BzD+Rj5J7YiZxakAOhzplQoe+G1+pKdjI0cX8WBSYVKXINk6DMlKCLZhSGYHn0nBRKY8 PArINcCI2VT7EzZKS8YjjCK5TJiC+5bfWB86aaWMyQPS518VUmLbB+Ssj5kBqtWGegzI wna9shbEcN5Y2HpT99kXi1Sb7yAGe+K87qQjGYEfWdbU9cWT/ypmRII7IizfF2WnrUdF zUT9hF9roDU9cqUsRiszWVcuV751b1nWdLoc59qGkbmPVCB5kkYm5QOWx6WH4npqlwF2 GccQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=09gxlNXz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j8si6899184edp.407.2020.11.09.05.30.27; Mon, 09 Nov 2020 05:30:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=09gxlNXz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733088AbgKINOO (ORCPT + 99 others); Mon, 9 Nov 2020 08:14:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:40346 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729958AbgKINOM (ORCPT ); Mon, 9 Nov 2020 08:14:12 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BDAC020789; Mon, 9 Nov 2020 13:14:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604927650; bh=Yb+poyMjHvPJ5NCCLX6WjKFIr6arh83gmJcZlwD9Pe4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=09gxlNXzvHMTfU3kymvxmfh0JGAFIsj2ecQd6ccfqAR2XhUOLPFTARF74LyFXqAvc bEbMk5vO06V62tGai5R63+PXhE1E+4rShb7GzcFyxLTbXHbrtp0J7+h/3faCTifsA0 otaKHaUqK3V7MJaYjGZBA9lY5p9ca93G+rxwbmBU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jun Li , Peter Chen , Sasha Levin Subject: [PATCH 5.4 59/85] usb: cdns3: gadget: suspicious implicit sign extension Date: Mon, 9 Nov 2020 13:55:56 +0100 Message-Id: <20201109125025.406163166@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201109125022.614792961@linuxfoundation.org> References: <20201109125022.614792961@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Chen [ Upstream commit 5fca3f062879f8e5214c56f3e3e2be6727900f5d ] The code: trb->length = cpu_to_le32(TRB_BURST_LEN(priv_ep->trb_burst_size) | TRB_LEN(length)); TRB_BURST_LEN(priv_ep->trb_burst_size) may be overflow for int 32 if priv_ep->trb_burst_size is equal or larger than 0x80; Below is the Coverity warning: sign_extension: Suspicious implicit sign extension: priv_ep->trb_burst_size with type u8 (8 bits, unsigned) is promoted in priv_ep->trb_burst_size << 24 to type int (32 bits, signed), then sign-extended to type unsigned long (64 bits, unsigned). If priv_ep->trb_burst_size << 24 is greater than 0x7FFFFFFF, the upper bits of the result will all be 1. To fix it, it needs to add an explicit cast to unsigned int type for ((p) << 24). Reviewed-by: Jun Li Signed-off-by: Peter Chen Signed-off-by: Sasha Levin --- drivers/usb/cdns3/gadget.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/cdns3/gadget.h b/drivers/usb/cdns3/gadget.h index bc4024041ef26..ec5c05454531d 100644 --- a/drivers/usb/cdns3/gadget.h +++ b/drivers/usb/cdns3/gadget.h @@ -1057,7 +1057,7 @@ struct cdns3_trb { #define TRB_TDL_SS_SIZE_GET(p) (((p) & GENMASK(23, 17)) >> 17) /* transfer_len bitmasks - bits 31:24 */ -#define TRB_BURST_LEN(p) (((p) << 24) & GENMASK(31, 24)) +#define TRB_BURST_LEN(p) ((unsigned int)((p) << 24) & GENMASK(31, 24)) #define TRB_BURST_LEN_GET(p) (((p) & GENMASK(31, 24)) >> 24) /* Data buffer pointer bitmasks*/ -- 2.27.0