Skip to content

Commit 9ab96b5

Browse files
Muchun Songakpm00
authored andcommitted
hugetlb: fix NULL pointer dereference in trace_hugetlbfs_alloc_inode
hugetlb_file_setup() will pass a NULL @dir to hugetlbfs_get_inode(), so we will access a NULL pointer for @dir. Fix it and set __entry->dr to 0 if @dir is NULL. Because ->i_ino cannot be 0 (see get_next_ino()), there is no confusing if user sees a 0 inode number. Link: https://lkml.kernel.org/r/[email protected] Fixes: 318580a ("hugetlbfs: support tracepoint") Signed-off-by: Muchun Song <[email protected]> Reported-by: Cheung Wall <[email protected]> Closes: https://lore.kernel.org/linux-mm/[email protected]/T/# Reviewed-by: Hongbo Li <[email protected]> Cc: cheung wall <[email protected]> Cc: Christian Brauner <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 4ce718f commit 9ab96b5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/trace/events/hugetlbfs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ TRACE_EVENT(hugetlbfs_alloc_inode,
2323
TP_fast_assign(
2424
__entry->dev = inode->i_sb->s_dev;
2525
__entry->ino = inode->i_ino;
26-
__entry->dir = dir->i_ino;
26+
__entry->dir = dir ? dir->i_ino : 0;
2727
__entry->mode = mode;
2828
),
2929

0 commit comments

Comments
 (0)