From ed54397b414def44d8ef11b4e320d9809d5fa294 Mon Sep 17 00:00:00 2001 From: zhanchengbin Date: Fri, 31 Dec 2021 15:42:17 +0800 Subject: [PATCH] libsupport: avoid possible null dereference in quota_set_sb_inum() If the quota type is invalid, quota_sb_inump will return NULL; this should not cause the program to crash. Link: https://lore.kernel.org/r/ee0b034c-71f3-63b7-a8de-d8e7760b9545@huawei.com Signed-off-by: zhanchengbin Signed-off-by: Theodore Ts'o --- lib/support/mkquota.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/support/mkquota.c b/lib/support/mkquota.c index 5de7c48..c89f895 100644 --- a/lib/support/mkquota.c +++ b/lib/support/mkquota.c @@ -99,6 +99,8 @@ void quota_set_sb_inum(ext2_filsys fs, ext2_ino_t ino, enum quota_type qtype) log_debug("setting quota ino in superblock: ino=%u, type=%d", ino, qtype); + if (inump == NULL) + return; *inump = ino; ext2fs_mark_super_dirty(fs); } -- 1.8.3.1