fs: avoid possible NULL dereference in fs_devread
PATCH 1/1 fs: avoid possible NULL dereference in fs_devread
It is unwise to first dereference a variable
and then to check if it was NULL.
Signed-off-by Heinrich Schuchardt <[email protected]>
--- fs/fs_internal.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/fs_internal.c +2 -1
@@ -15,12 +15,13 @@ int fs_devread(struct blk_desc *blk, disk_partition_t *partition, lbaint_t sector, int byte_offset, int byte_len, char *buf) { unsigned block_len; -int log2blksz = blk->log2blksz; +int log2blksz;ALLOC_CACHE_ALIGN_BUFFER (char, sec_buf, (blk ? blk->blksz :0 ));if (blk ==NULL ) {printf ("** Invalid Block Device Descriptor (NULL)\n" );return 0 ; } + log2blksz = blk->log2blksz;/* Check partition boundaries */ if ((sector + ((byte_offset + byte_len - 1) >> log2blksz))
Signature · 1 line
2.15.0
PATCH 1/1 fs: avoid possible NULL dereference in fs_devread
Reviewed-by Marek Behun <[email protected]>
PATCH 1/1 fs: avoid possible NULL dereference in fs_devread
In reply to Heinrich SchuchardtQuoted 8 lines · Heinrich Schuchardt
It is unwise to first dereference a variable
and then to check if it was NULL.Signed-off-by Heinrich Schuchardt <[email protected]>--- fs/fs_internal.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Reviewed-by Bin Meng <[email protected]>
PATCH 1/1 fs: avoid possible NULL dereference in fs_devread
In reply to Heinrich SchuchardtQuoted 6 lines · Heinrich Schuchardt
It is unwise to first dereference a variable and then to check if it was NULL.
Signed-off-by Heinrich Schuchardt <[email protected]>Reviewed-by Marek Behun <[email protected]>Reviewed-by Bin Meng <[email protected]>
Applied to u-boot/master, thanks!
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/20171130/9fc94e17/attachment.sig>