cmd: usb_mass_storage: add protection for block_dev
PATCH 1/1 cmd: usb_mass_storage: add protection for block_dev
Hi Marek and Lucaz
I have found this old patch: See https://lists.denx.de/pipermail/u-boot/2017-October/309716.html
Quoted 30 lines · On 10/18/2017 10:22 PM, Marek Vasut-3 wrote:
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 withblock_dev= 0 whenCONFIG_CMD_UBIFSis activate and ubi volume is mountedSigned-off-by Patrick Delaunay <[hidden email]>This is UMS, so Lukasz ... please review _thoroughly_ , as I suspect there might be some weird underlying issue .
Quoted 17 lines
Quoted 17 lines
---
cmd/usb_mass_storage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)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;
Quoted 7 lines
Quoted 4 lines
cmd/usb_mass_storage.c static int ums_init(const char *devtype, const char *devnums_part_str) · line 91
Quoted 1 line
cmd/usb_mass_storage.c +0
-0ums_new =realloc (ums, (ums_count +1 ) *sizeof (*ums));Adding in Marek..
Signature · 2 lines
Best regards, Marek Vasut
Do you think that this patch is needed.
I check and the issue is still present on U-Boot v2018.09 :
STM32MP> ubi part UBI
STM32MP> ubifsmount ubi0:boot
STM32MP> ums 0 ubi 0
data abort
pc : [<ffc60abc>] lr : [<ffc60ab3>]
reloc pc : [<c0110abc>] lr : [<c0110ab3>]
sp : fdc3e460 ip : fdc3e518 fp : fdcf06a8
r10: fdcf06b8 r9 : fdc4eed8 r8 : 00000000
r7 : ffce3d84 r6 : fdcf0740 r5 : fdcf0740 r4 : ffce3d88
r3 : 00000000 r2 : 00000000 r1 : 0000003a r0 : 00000000
Flags: nZCv IRQs off FIQs off Mode SVC_32
Code: f04f4628 9b06fd2a bf082800 0800f04f (f5b3695b)
Resetting CPU ...
Even If the command is invalid, I think that data abort should be avoid.
Regards
Patrick
PATCH 1/1 cmd: usb_mass_storage: add protection for block_dev
Quoted 58 lines · Patrick DELAUNAY
Hi Marek and Lucaz
I have found this old patch: See https://lists.denx.de/pipermail/u-boot/2017-October/309716.html
Quoted 30 lines · On 10/18/2017 10:22 PM, Marek Vasut-3 wrote:
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 withblock_dev= 0 whenCONFIG_CMD_UBIFSis activate and ubi volume is mountedSigned-off-by Patrick Delaunay <[hidden email]>This is UMS, so Lukasz ... please review _thoroughly_ , as I suspect there might be some weird underlying issue .
Quoted 17 lines
Quoted 17 lines
---
cmd/usb_mass_storage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)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;Quoted 7 lines
Quoted 4 lines
cmd/usb_mass_storage.c static int ums_init(const char *devtype, const char *devnums_part_str) · line 91
Quoted 1 line
cmd/usb_mass_storage.c +0
-0ums_new =realloc (ums, (ums_count +1 ) *sizeof (*ums));Adding in Marek..
Signature · 2 lines
Best regards, Marek VasutDo you think that this patch is needed.
I check and the issue is still present on U-Boot v2018.09 :STM32MP> ubi part UBI
STM32MP> ubifsmount ubi0:boot
STM32MP> ums 0 ubi 0
data abortpc : [<ffc60abc>] lr : [<ffc60ab3>]reloc pc : [<
c0110abc>] lr : [<c0110ab3>]
sp :fdc3e460ip :fdc3e518fp :fdcf06a8
r10:fdcf06b8r9 :fdc4eed8r8 : 00000000
r7 :ffce3d84r6 :fdcf0740r5 :fdcf0740r4 :ffce3d88
r3 : 00000000 r2 : 00000000 r1 :0000003ar0 : 00000000
Flags: nZCv IRQs off FIQs off ModeSVC_32
Quoted 4 lines
Code: f04f4628 9b06fd2a bf082800 0800f04f (f5b3695b)Resetting CPU ...
Even If the command is invalid, I think that data abort should be avoid.
I think so too, send an updated patch please.
Signature · 2 lines
Best regards, Marek Vasut