mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-27 16:01:27 +00:00
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>
This commit is contained in:
parent
254eedee7f
commit
24f48416df
1 changed files with 2 additions and 1 deletions
|
@ -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)
|
lbaint_t sector, int byte_offset, int byte_len, char *buf)
|
||||||
{
|
{
|
||||||
unsigned block_len;
|
unsigned block_len;
|
||||||
int log2blksz = blk->log2blksz;
|
int log2blksz;
|
||||||
ALLOC_CACHE_ALIGN_BUFFER(char, sec_buf, (blk ? blk->blksz : 0));
|
ALLOC_CACHE_ALIGN_BUFFER(char, sec_buf, (blk ? blk->blksz : 0));
|
||||||
if (blk == NULL) {
|
if (blk == NULL) {
|
||||||
printf("** Invalid Block Device Descriptor (NULL)\n");
|
printf("** Invalid Block Device Descriptor (NULL)\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
log2blksz = blk->log2blksz;
|
||||||
|
|
||||||
/* Check partition boundaries */
|
/* Check partition boundaries */
|
||||||
if ((sector + ((byte_offset + byte_len - 1) >> log2blksz))
|
if ((sector + ((byte_offset + byte_len - 1) >> log2blksz))
|
||||||
|
|
Loading…
Add table
Reference in a new issue