* [U-Boot] [PATCH 1/1] fs: avoid possible NULL dereference in fs_devread
@ 2017-11-19 22:49 Heinrich Schuchardt
2017-11-20 1:58 ` Marek Behun
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Heinrich Schuchardt @ 2017-11-19 22:49 UTC (permalink / raw)
To: u-boot
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>
---
fs/fs_internal.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/fs_internal.c b/fs/fs_internal.c
index 58b441030c..5cdd272c9d 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))
--
2.15.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH 1/1] fs: avoid possible NULL dereference in fs_devread
2017-11-19 22:49 [U-Boot] [PATCH 1/1] fs: avoid possible NULL dereference in fs_devread Heinrich Schuchardt
@ 2017-11-20 1:58 ` Marek Behun
2017-11-20 9:36 ` Bin Meng
2017-11-30 15:36 ` [U-Boot] [U-Boot, " Tom Rini
2 siblings, 0 replies; 4+ messages in thread
From: Marek Behun @ 2017-11-20 1:58 UTC (permalink / raw)
To: u-boot
Reviewed-by: Marek Behun <marek.behun@nic.cz>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH 1/1] fs: avoid possible NULL dereference in fs_devread
2017-11-19 22:49 [U-Boot] [PATCH 1/1] fs: avoid possible NULL dereference in fs_devread Heinrich Schuchardt
2017-11-20 1:58 ` Marek Behun
@ 2017-11-20 9:36 ` Bin Meng
2017-11-30 15:36 ` [U-Boot] [U-Boot, " Tom Rini
2 siblings, 0 replies; 4+ messages in thread
From: Bin Meng @ 2017-11-20 9:36 UTC (permalink / raw)
To: u-boot
On Mon, Nov 20, 2017 at 6:49 AM, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
> 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>
> ---
> fs/fs_internal.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [U-Boot, 1/1] fs: avoid possible NULL dereference in fs_devread
2017-11-19 22:49 [U-Boot] [PATCH 1/1] fs: avoid possible NULL dereference in fs_devread Heinrich Schuchardt
2017-11-20 1:58 ` Marek Behun
2017-11-20 9:36 ` Bin Meng
@ 2017-11-30 15:36 ` Tom Rini
2 siblings, 0 replies; 4+ messages in thread
From: Tom Rini @ 2017-11-30 15:36 UTC (permalink / raw)
To: u-boot
On Sun, Nov 19, 2017 at 11:49:21PM +0100, Heinrich Schuchardt wrote:
> 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>
Applied to u-boot/master, thanks!
--
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>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-11-30 15:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-19 22:49 [U-Boot] [PATCH 1/1] fs: avoid possible NULL dereference in fs_devread Heinrich Schuchardt
2017-11-20 1:58 ` Marek Behun
2017-11-20 9:36 ` Bin Meng
2017-11-30 15:36 ` [U-Boot] [U-Boot, " Tom Rini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox