Skip to content

Commit

Permalink
hugetlb: fix NULL pointer dereference in trace_hugetlbfs_alloc_inode
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Muchun Song authored and akpm00 committed Jan 13, 2025
1 parent 4ce718f commit 9ab96b5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/trace/events/hugetlbfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ TRACE_EVENT(hugetlbfs_alloc_inode,
TP_fast_assign(
__entry->dev = inode->i_sb->s_dev;
__entry->ino = inode->i_ino;
__entry->dir = dir->i_ino;
__entry->dir = dir ? dir->i_ino : 0;
__entry->mode = mode;
),

Expand Down

0 comments on commit 9ab96b5

Please sign in to comment.