Skip to contentSkip to conversation

cmd: usb_mass_storage: add protection for block_dev

PATCH New Patrick Delaunay 3 participants 3 messages Oct 18, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmd: usb_mass_storage: add protection for block_dev

solve data abort for the command "ums 0 ubi 0" because result of case blk_get_device_part_str() result is OK but with block_dev = 0 when CONFIG_CMD_UBIFS is activate and ubi volume is mounted

---

 cmd/usb_mass_storage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cmd/usb_mass_storage.c +1 -1
index cfeecb7..c0563ca 100644
@@ -85,7 +85,7 @@ static int ums_init(const char *devtype, const char *devnums_part_str)
 			partnum = 0;
 
 		/* f_mass_storage.c assumes SECTOR_SIZE sectors */
-		if (block_dev->blksz != SECTOR_SIZE)
+		if (!block_dev || block_dev->blksz != SECTOR_SIZE)
 			goto cleanup;
 
 		ums_new = realloc(ums, (ums_count + 1) * sizeof(*ums));
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 cmd: usb_mass_storage: add protection for block_dev

Quoted 16 lines · Patrick Delaunay

solve data abort for the command "ums 0 ubi 0" because result of case blk_get_device_part_str() result is OK but with block_dev = 0 when CONFIG_CMD_UBIFS is activate and ubi volume is mounted

---

 cmd/usb_mass_storage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cmd/usb_mass_storage.c +0 -0
index cfeecb7..c0563ca 100644

cmd/usb_mass_storage.c static int ums_init(const char *devtype, const char *devnums_part_str) · line 91

Quoted 8 lines
cmd/usb_mass_storage.c +1 -1
@@ -85,7 +85,7 @@ static int ums_init(const char *devtype, const char *devnums_part_str)
 			partnum = 0;
 
 		/* f_mass_storage.c assumes SECTOR_SIZE sectors */
-		if (block_dev->blksz != SECTOR_SIZE)
+		if (!block_dev || block_dev->blksz != SECTOR_SIZE)
 			goto cleanup;
 
 		ums_new = realloc(ums, (ums_count + 1) * sizeof(*ums));

Adding in Marek..

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171018/6e56fe6f/attachment.sig>
#2 lore raw

PATCH 1/1 cmd: usb_mass_storage: add protection for block_dev

Quoted 8 lines · Tom Rini
Quoted 6 lines · Patrick Delaunay

solve data abort for the command "ums 0 ubi 0" because result of case blk_get_device_part_str() result is OK but with block_dev = 0 when CONFIG_CMD_UBIFS is activate and ubi volume is mounted

This is UMS, so Lukasz ... please review _thoroughly_ , as I suspect there might be some weird underlying issue .

Quoted 21 lines
Quoted 10 lines

---

 cmd/usb_mass_storage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cmd/usb_mass_storage.c +0 -0
index cfeecb7..c0563ca 100644

cmd/usb_mass_storage.c static int ums_init(const char *devtype, const char *devnums_part_str) · line 91

Quoted 8 lines
cmd/usb_mass_storage.c +1 -1
@@ -85,7 +85,7 @@ static int ums_init(const char *devtype, const char *devnums_part_str)
 			partnum = 0;
 
 		/* f_mass_storage.c assumes SECTOR_SIZE sectors */
-		if (block_dev->blksz != SECTOR_SIZE)
+		if (!block_dev || block_dev->blksz != SECTOR_SIZE)
 			goto cleanup;
 
 		ums_new = realloc(ums, (ums_count + 1) * sizeof(*ums));

Adding in Marek..

Signature · 2 lines
Best regards,
Marek Vasut