Skip to contentSkip to conversation

usb: storage: Fix overwritten in usb_stor_set_max_xfer_blk()

PATCH New Bin Meng 2 participants 8 messages Sep 28, 2017 – Oct 1, 2017

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

PATCH 1/1 usb: storage: Fix overwritten in usb_stor_set_max_xfer_blk()

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)

---

 common/usb_storage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/usb_storage.c +1 -1
index a57570b..a91b1c0 100644
@@ -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
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 usb: storage: Fix overwritten in usb_stor_set_max_xfer_blk()

Quoted 7 lines · Bin Meng

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)

Still failing
https://travis-ci.org/marex/u-boot-usb/builds/280835848

Quoted 19 lines

---

 common/usb_storage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/usb_storage.c +1 -1
index a57570b..a91b1c0 100644
@@ -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
Signature · 2 lines
Best regards,
Marek Vasut
author
#2 lore raw

PATCH 1/1 usb: storage: Fix overwritten in usb_stor_set_max_xfer_blk()

Hi Marek,

Quoted 6 lines · Marek Vasut
Quoted 5 lines · Bin Meng

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.

Quoted 6 lines
Quoted 2 lines
Reported-by Coverity (CID: 167250)

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.

Quoted 5 lines
Quoted 5 lines

---

 common/usb_storage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines
Quoted 6 lines
common/usb_storage.c +0 -0
index a57570b..a91b1c0 100644

common/usb_storage.c static void usb_stor_set_max_xfer_blk(struct usb_device *udev, · line 970

Quoted 8 lines
common/usb_storage.c +1 -1
@@ -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

#3 lore raw

PATCH 1/1 usb: storage: Fix overwritten in usb_stor_set_max_xfer_blk()

Quoted 12 lines · Bin Meng

Hi Marek,

Quoted 9 lines · Marek Vasut
Quoted 7 lines · Bin Meng

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)
Quoted 6 lines
Quoted 3 lines

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.

Can't you send me fix on top of current set ? If not, OK, tell me what to drop and what to pick.

Thanks

Quoted 23 lines
Quoted 5 lines
Quoted 5 lines

---

 common/usb_storage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines
Quoted 6 lines
common/usb_storage.c +0 -0
index a57570b..a91b1c0 100644

common/usb_storage.c static void usb_stor_set_max_xfer_blk(struct usb_device *udev, · line 970

Quoted 8 lines
common/usb_storage.c +1 -1
@@ -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

Signature · 2 lines
Best regards,
Marek Vasut
author
#4 lore raw

PATCH 1/1 usb: storage: Fix overwritten in usb_stor_set_max_xfer_blk()

Hi Marek,

Quoted 17 lines · Marek Vasut
Quoted 16 lines · Bin Meng

Hi Marek,

Quoted 12 lines · Marek Vasut
Quoted 7 lines · Bin Meng

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)

Still failing
https://travis-ci.org/marex/u-boot-usb/builds/280835848

Quoted 6 lines
Quoted 2 lines

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.

Can't you send me fix on top of current set ? If not, OK, tell me what to drop and what to pick.

OK, will do.

Regards,
Bin

#5 lore raw

PATCH 1/1 usb: storage: Fix overwritten in usb_stor_set_max_xfer_blk()

Quoted 20 lines · Bin Meng

Hi Marek,

Quoted 17 lines · Marek Vasut
Quoted 16 lines · Bin Meng

Hi Marek,

Quoted 12 lines · Marek Vasut
Quoted 7 lines · Bin Meng

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)

Still failing
https://travis-ci.org/marex/u-boot-usb/builds/280835848

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

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.

Can't you send me fix on top of current set ? If not, OK, tell me what to drop and what to pick.

OK, will do.

Thanks!

Signature · 2 lines
Best regards,
Marek Vasut
author
#6 lore raw

PATCH 1/1 usb: storage: Fix overwritten in usb_stor_set_max_xfer_blk()

Hi Marek,

Quoted 24 lines · Marek Vasut
Quoted 23 lines · Bin Meng

Hi Marek,

Quoted 20 lines · Marek Vasut
Quoted 18 lines · Bin Meng

Hi Marek,

Quoted 6 lines · Marek Vasut
Quoted 5 lines · Bin Meng

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.

Quoted 6 lines
Quoted 2 lines
Reported-by Coverity (CID: 167250)

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.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Can't you send me fix on top of current set ? If not, OK, tell me what to drop and what to pick.

OK, will do.

Thanks!

I just sent additional patches
(http://patchwork.ozlabs.org/project/uboot/list/?series=5892) to fix the 'make tests' issues.

Please do the following on the u-boot-usb/master branch:

1). Drop http://git.denx.de/?p=u-boot/u-boot-usb.git;a=commit;h=198db64035a589ef19920b2cec58419b4b338ce7
2). Drop http://git.denx.de/?p=u-boot/u-boot-usb.git;a=commit;h=9a462a3af216d77fee689f119419506218531f77
3). Apply http://patchwork.ozlabs.org/project/uboot/list/?series=5892
on top of u-boot-usb/master

Then everything should be fine.

Regards,
Bin

#7 lore raw

PATCH 1/1 usb: storage: Fix overwritten in usb_stor_set_max_xfer_blk()

Quoted 40 lines · Bin Meng

Hi Marek,

Quoted 24 lines · Marek Vasut
Quoted 23 lines · Bin Meng

Hi Marek,

Quoted 20 lines · Marek Vasut
Quoted 18 lines · Bin Meng

Hi Marek,

Quoted 6 lines · Marek Vasut
Quoted 5 lines · Bin Meng

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.

Quoted 6 lines
Quoted 2 lines
Reported-by Coverity (CID: 167250)

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.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Can't you send me fix on top of current set ? If not, OK, tell me what to drop and what to pick.

OK, will do.

Thanks!

I just sent additional patches
(http://patchwork.ozlabs.org/project/uboot/list/?series=5892) to fix the 'make tests' issues.

Quoted 8 lines

Please do the following on the u-boot-usb/master branch:

1). Drop http://git.denx.de/?p=u-boot/u-boot-usb.git;a=commit;h=198db64035a589ef19920b2cec58419b4b338ce7
2). Drop http://git.denx.de/?p=u-boot/u-boot-usb.git;a=commit;h=9a462a3af216d77fee689f119419506218531f77
3). Apply http://patchwork.ozlabs.org/project/uboot/list/?series=5892
on top of u-boot-usb/master

Then everything should be fine.

Build tests pass, PR out, thanks !

Signature · 2 lines
Best regards,
Marek Vasut