* [f2fs-dev] [PATCH v2] fsck.f2fs: fix potential NULL dereference
@ 2023-06-02 10:26 Maxim Korotkov
2023-06-05 4:23 ` Chao Yu
0 siblings, 1 reply; 2+ messages in thread
From: Maxim Korotkov @ 2023-06-02 10:26 UTC (permalink / raw)
To: Chao Yu; +Cc: Maxim Korotkov, Maxim Korotkov, linux-f2fs-devel
The input pointer "parent" was used unsafely
before checking against NULL
Found by RASU JSC with Svace static analyzer
Fixes: 603f8f9d3(sload.f2fs: support loading files into partition directly)
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Maxim Korotkov <maskorotkov@rasu.ru>
---
changelog: removed trailing indent
fsck/dir.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/fsck/dir.c b/fsck/dir.c
index 4a3eb6e..10d0310 100644
--- a/fsck/dir.c
+++ b/fsck/dir.c
@@ -225,19 +225,23 @@ int f2fs_add_link(struct f2fs_sb_info *sbi, struct f2fs_node *parent,
int level = 0, current_depth, bit_pos;
int nbucket, nblock, bidx, block;
int slots = GET_DENTRY_SLOTS(name_len);
- f2fs_hash_t dentry_hash = f2fs_dentry_hash(get_encoding(sbi),
- IS_CASEFOLDED(&parent->i),
- name, name_len);
+ f2fs_hash_t dentry_hash;
struct f2fs_dentry_block *dentry_blk;
struct f2fs_dentry_ptr d;
struct dnode_of_data dn;
- nid_t pino = le32_to_cpu(parent->footer.ino);
- unsigned int dir_level = parent->i.i_dir_level;
+ nid_t pino;
+ unsigned int dir_level;
int ret;
if (parent == NULL)
return -EINVAL;
+ dentry_hash = f2fs_dentry_hash(get_encoding(sbi),
+ IS_CASEFOLDED(&parent->i),
+ name, name_len);
+ pino = le32_to_cpu(parent->footer.ino);
+ dir_level = parent->i.i_dir_level;
+
if (!pino) {
ERR_MSG("Wrong parent ino:%d \n", pino);
return -EINVAL;
--
2.34.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [f2fs-dev] [PATCH v2] fsck.f2fs: fix potential NULL dereference
2023-06-02 10:26 [f2fs-dev] [PATCH v2] fsck.f2fs: fix potential NULL dereference Maxim Korotkov
@ 2023-06-05 4:23 ` Chao Yu
0 siblings, 0 replies; 2+ messages in thread
From: Chao Yu @ 2023-06-05 4:23 UTC (permalink / raw)
To: Maxim Korotkov; +Cc: Maxim Korotkov, linux-f2fs-devel
On 2023/6/2 18:26, Maxim Korotkov wrote:
> The input pointer "parent" was used unsafely
> before checking against NULL
>
> Found by RASU JSC with Svace static analyzer
> Fixes: 603f8f9d3(sload.f2fs: support loading files into partition directly)
> Reviewed-by: Chao Yu <chao@kernel.org>
> Signed-off-by: Maxim Korotkov <maskorotkov@rasu.ru>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-06-05 4:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-02 10:26 [f2fs-dev] [PATCH v2] fsck.f2fs: fix potential NULL dereference Maxim Korotkov
2023-06-05 4:23 ` Chao Yu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.