mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-02 09:46:37 +03:00
fs: erofs: Do NULL check before dereferencing pointer
The assignments to sect and off use the pointer from ctxt.cur_dev but that has not been NULL checked before this is done. So instead move the assignments after the NULL check. This issue found by Smatch Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org> Reviewed-by: Gao Xiang <xiang@kernel.org>
This commit is contained in:
committed by
Tom Rini
parent
a21ec39944
commit
ff8a41ce49
@@ -11,12 +11,15 @@ static struct erofs_ctxt {
|
||||
|
||||
int erofs_dev_read(int device_id, void *buf, u64 offset, size_t len)
|
||||
{
|
||||
lbaint_t sect = offset >> ctxt.cur_dev->log2blksz;
|
||||
int off = offset & (ctxt.cur_dev->blksz - 1);
|
||||
lbaint_t sect;
|
||||
int off;
|
||||
|
||||
if (!ctxt.cur_dev)
|
||||
return -EIO;
|
||||
|
||||
sect = offset >> ctxt.cur_dev->log2blksz;
|
||||
off = offset & (ctxt.cur_dev->blksz - 1);
|
||||
|
||||
if (fs_devread(ctxt.cur_dev, &ctxt.cur_part_info, sect,
|
||||
off, len, buf))
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user