From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bin Meng Date: Fri, 29 Sep 2017 07:36:18 +0800 Subject: [U-Boot] [PATCH] usb: storage: Fix overwritten in usb_stor_set_max_xfer_blk() In-Reply-To: <3de48db9-ed77-4d9f-8d87-7cf31c5a7881@denx.de> References: <1506574207-28971-1-git-send-email-bmeng.cn@gmail.com> <3de48db9-ed77-4d9f-8d87-7cf31c5a7881@denx.de> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Marek, On Thu, Sep 28, 2017 at 11:24 PM, Marek Vasut wrote: > On 09/28/2017 06:50 AM, Bin Meng wrote: >> The stored 'blk' value is overwritten to 'size / 512' before it can >> be used in usb_stor_set_max_xfer_blk(). This is not what we want. >> In fact, when 'size' exceeds the upper limit (USHRT_MAX * 512), we >> should simply assign 'size' to the upper limit. >> >> Reported-by: Coverity (CID: 167250) >> Signed-off-by: Bin Meng > > Still failing > https://travis-ci.org/marex/u-boot-usb/builds/280835848 > This fixes the Coverity issue, not the 'make tests' issue. Please hold on apply the xHCI patchset and when the fix is ready I will send v2. >> --- >> >> common/usb_storage.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/common/usb_storage.c b/common/usb_storage.c >> index a57570b..a91b1c0 100644 >> --- a/common/usb_storage.c >> +++ b/common/usb_storage.c >> @@ -964,7 +964,7 @@ static void usb_stor_set_max_xfer_blk(struct usb_device *udev, >> blk = 20; >> } else { >> if (size > USHRT_MAX * 512) >> - blk = USHRT_MAX; >> + size = USHRT_MAX * 512; >> blk = size / 512; >> } >> #endif >> Regards, Bin