summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2017-11-19 23:49:21 +0100
committerTom Rini <trini@konsulko.com>2017-11-29 22:30:50 -0500
commit24f48416dfe1d827dcf759d6cd0e7a8e5c67e321 (patch)
treea7e03593cbaff32b04b97c716428e629d016c3ba /fs
parent254eedee7f383066b70ac4da01bc792a3256a4b3 (diff)
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 <xypron.glpk@gmx.de> Reviewed-by: Marek Behun <marek.behun@nic.cz> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/fs_internal.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/fs_internal.c b/fs/fs_internal.c
index 58b441030c8..5cdd272c9de 100644
--- a/fs/fs_internal.c
+++ b/fs/fs_internal.c
@@ -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))