projects
/
project
/
bcm63xx
/
u-boot.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
254eede
)
fs: avoid possible NULL dereference in fs_devread
author
Heinrich Schuchardt
<
[email protected]
>
Sun, 19 Nov 2017 22:49:21 +0000
(23:49 +0100)
committer
Tom Rini
<
[email protected]
>
Thu, 30 Nov 2017 03:30:50 +0000
(22:30 -0500)
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]
>
fs/fs_internal.c
patch
|
blob
|
history
diff --git
a/fs/fs_internal.c
b/fs/fs_internal.c
index 58b441030c863dda0ce0ea202b949735e088d024..5cdd272c9de1ce59cfa252da4316aa8a052a5f0d 100644
(file)
--- 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))