From: zhanchengbin Date: Fri, 31 Dec 2021 07:42:17 +0000 (+0800) Subject: libsupport: avoid possible null dereference in quota_set_sb_inum() X-Git-Tag: v1.46.6-rc1~55 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=ed54397b414def44d8ef11b4e320d9809d5fa294;p=tools%2Fe2fsprogs.git 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 --- 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); }