Message ID | 20180604114556epcas1p373ba4abe43a2441abc99c8c17a757aec~08nSs2JOq1074810748epcas1p32@epcas1p3.samsung.com |
---|---|
State | Accepted |
Commit | 6e2151c729674aecabf5ec5a96dac97433632009 |
Delegated to: | Tom Rini |
Headers | show |
Series | [U-Boot] fs: fat: fix wrong casting to unsigned value of sect_to_cluster() | expand |
On Mon, Jun 04, 2018 at 08:45:54PM +0900, Seung-Woo Kim wrote: > After the commit 265edc03d5a1 ("fs/fat: Clean up open-coded sector > <-> cluster conversions"), it is hung up writing new file to FAT16 > disk with more than 19 files in armv7. It is because result value > of sect_to_cluster() is not proper by casting from signed value to > unsigned value. Fix the wrong casting of sect_to_cluster(). > > Reported-by: Jaehoon Chung <jh80.chung@samsung.com> > Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com> > --- > include/fat.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Can you please also update test/fs-test.sh with a testcase for this? Thanks!
Hello, On 2018년 06월 05일 06:58, Tom Rini wrote: > On Mon, Jun 04, 2018 at 08:45:54PM +0900, Seung-Woo Kim wrote: > >> After the commit 265edc03d5a1 ("fs/fat: Clean up open-coded sector >> <-> cluster conversions"), it is hung up writing new file to FAT16 >> disk with more than 19 files in armv7. It is because result value >> of sect_to_cluster() is not proper by casting from signed value to >> unsigned value. Fix the wrong casting of sect_to_cluster(). >> >> Reported-by: Jaehoon Chung <jh80.chung@samsung.com> >> Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com> >> --- >> include/fat.h | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) > > Can you please also update test/fs-test.sh with a testcase for this? > Thanks! > The simple test way is doing fat-write more than 20 files with long file name to FAT16 image. For example, in my armv7 odroid-xu3 target with empty fat16 root, writing like following: fatwrite mmc 0 13000000 01000000000000000000 4 fatwrite mmc 0 13000000 02000000000000000000 4 .. fatwrite mmc 0 13000000 21000000000000000000 4 and then 22th writing was failed like following: ODROID-XU3 # fatwrite mmc 0 13000000 22000000000000000000 4 writing 22000000000000000000 Error: Invalid FAT entry: 0x3ffffffa Invalid FAT entry Error: Invalid FAT entry: 0x3ffffffa I tested same thing with sandbox u-boot on x86, there was no error like armv7. So, I am not sure it is helpful to add testcase for this. Best Regards, - Seung-Woo Kim
Hi Seung-Woo, > After the commit 265edc03d5a1 ("fs/fat: Clean up open-coded sector > <-> cluster conversions"), it is hung up writing new file to FAT16 > disk with more than 19 files in armv7. It is because result value > of sect_to_cluster() is not proper by casting from signed value to > unsigned value. Fix the wrong casting of sect_to_cluster(). > > Reported-by: Jaehoon Chung <jh80.chung@samsung.com> > Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com> > --- > include/fat.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/fat.h b/include/fat.h > index 7dada41..09e1423 100644 > --- a/include/fat.h > +++ b/include/fat.h > @@ -180,7 +180,7 @@ static inline u32 clust_to_sect(fsdata *fsdata, > u32 clust) return fsdata->data_begin + clust * fsdata->clust_size; > } > > -static inline u32 sect_to_clust(fsdata *fsdata, u32 sect) > +static inline u32 sect_to_clust(fsdata *fsdata, int sect) > { > return (sect - fsdata->data_begin) / fsdata->clust_size; > } Reviewed-by: Lukasz Majewski <lukma@denx.de> Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de
On Mon, Jun 04, 2018 at 08:45:54PM +0900, Seung-Woo Kim wrote: > After the commit 265edc03d5a1 ("fs/fat: Clean up open-coded sector > <-> cluster conversions"), it is hung up writing new file to FAT16 > disk with more than 19 files in armv7. It is because result value > of sect_to_cluster() is not proper by casting from signed value to > unsigned value. Fix the wrong casting of sect_to_cluster(). > > Reported-by: Jaehoon Chung <jh80.chung@samsung.com> > Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com> > Reviewed-by: Lukasz Majewski <lukma@denx.de> Applied to u-boot/master, thanks!
diff --git a/include/fat.h b/include/fat.h index 7dada41..09e1423 100644 --- a/include/fat.h +++ b/include/fat.h @@ -180,7 +180,7 @@ static inline u32 clust_to_sect(fsdata *fsdata, u32 clust) return fsdata->data_begin + clust * fsdata->clust_size; } -static inline u32 sect_to_clust(fsdata *fsdata, u32 sect) +static inline u32 sect_to_clust(fsdata *fsdata, int sect) { return (sect - fsdata->data_begin) / fsdata->clust_size; }
After the commit 265edc03d5a1 ("fs/fat: Clean up open-coded sector <-> cluster conversions"), it is hung up writing new file to FAT16 disk with more than 19 files in armv7. It is because result value of sect_to_cluster() is not proper by casting from signed value to unsigned value. Fix the wrong casting of sect_to_cluster(). Reported-by: Jaehoon Chung <jh80.chung@samsung.com> Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com> --- include/fat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)