Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3198845pxb; Mon, 9 Nov 2020 05:24:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJy/i9Errpng0n869DtIRqqA3nYiyGdhKVSOSnGAp1lsPFvsMl700/fJJu8yBPfiI2SpoZfj X-Received: by 2002:a05:6402:783:: with SMTP id d3mr15615630edy.168.1604928289190; Mon, 09 Nov 2020 05:24:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604928289; cv=none; d=google.com; s=arc-20160816; b=Iq+sXNXoW8DWpcI48eLY9ZApvbvXJbdxBdi0dYuH4Vjm3HHXdqoJV9Kl/ovq+WnMIo otEShgUbiuhpWcgkI6SOiHd8CxJ6a3GrRHEQG9qrYp0cA8bvYocQld4IgT1oMxTJlUE1 XYM6Ott1FBU0zODwSZBpf0xOSOWvrcGw3OXYghg8bS2Wqvqig0lsMvmRS67diY8m8csU X0ZnmgZVaZ0wD6KXXGnKmQhmhFpEt370om51KWo9hDji8M+1KXx5CznBdAOiZDuGvtiM /2Pr0wfywdUX9PnnXbTUHFmQ2bgCgv06R/3YJnFsnMsZBgpk+aDrdfAN2A8ZWtQiCHTj hC0A== 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=YSdi/PaaE8dPQ57qY7uMNAuHKa4LWffJQx/q5804Lqk=; b=n+sVS6Q4n6HVpOsE3CzBdykb4DT8RicGWj0Gh/NJAJYiS8FN8FTqbP89xbIlber16t TrS5SIoxSRwSaYM0UIHmwe2iIk6q56ZZduzGYYvf6mchKg1X2kpvfSp7mYpkjTI3AQVI na7X9qXJRYNxzkg2V5oAGPh3XpsMqNQaaBTshL42hJV18SBQ0dmGG5Ez+zV0ON0pK0h/ F3lg1HdZyvOkS46b88dHsZs7tJ5uTKUSoV8TAfadL6raredgwUg34Zj+wOYt3eOQaCGf XhTznNqBIMQxrgHFZEPkXOCi2fgd3TLk8OjL/xsZarIOTJe/2QV7EKMdTcFVoQNwMu+c BFLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GHER4GEg; 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 z11si6816064ejr.354.2020.11.09.05.24.26; Mon, 09 Nov 2020 05:24:49 -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=GHER4GEg; 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 S1733098AbgKINWr (ORCPT + 99 others); Mon, 9 Nov 2020 08:22:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:49832 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388129AbgKINVx (ORCPT ); Mon, 9 Nov 2020 08:21:53 -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 14FD52065D; Mon, 9 Nov 2020 13:21:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604928112; bh=pVUynB4smWTSxPgjCWr8eQ4kLWOtP1rvGVYvEQklTOY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GHER4GEgb1KecEbhgQk7zxDbmhtPgQXqpD1OXznVJzp7vBLiwAC9BoJl1Pn94buvX +9yb5vpmRq22ixSj7RAYy6cY1wkfGGuP68TzsQuYNRagLUVdhKpySF7kobr718U223 PH8fkB1JcqbE3wzlgaAw9nzysKhZcbz2Aq66/qYs= 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.9 101/133] usb: cdns3: gadget: suspicious implicit sign extension Date: Mon, 9 Nov 2020 13:56:03 +0100 Message-Id: <20201109125035.547057101@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201109125030.706496283@linuxfoundation.org> References: <20201109125030.706496283@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 8212bddf6c8d1..5be0ff2ae079c 100644 --- a/drivers/usb/cdns3/gadget.h +++ b/drivers/usb/cdns3/gadget.h @@ -1067,7 +1067,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