Skip to content

Commit

Permalink
gfs2: Move variable assignment behind a null pointer check in inode_g…
Browse files Browse the repository at this point in the history
…o_dump

Since commit 27a2660 ("gfs2: Dump nrpages for inodes and their
glocks"), inode_go_dump() computes the address of inode within ip before
checking if ip is NULL.  This isn't a bug by itself, but it can give
rise to bugs later.  Avoid that by checking if ip is NULL first.

Signed-off-by: Markus Elfring <[email protected]>
Signed-off-by: Andreas Gruenbacher <[email protected]>
  • Loading branch information
elfring authored and Andreas Gruenbacher committed Apr 18, 2023
1 parent 130cf52 commit 55534c0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/gfs2/glops.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,12 +535,13 @@ static void inode_go_dump(struct seq_file *seq, struct gfs2_glock *gl,
const char *fs_id_buf)
{
struct gfs2_inode *ip = gl->gl_object;
struct inode *inode = &ip->i_inode;
struct inode *inode;
unsigned long nrpages;

if (ip == NULL)
return;

inode = &ip->i_inode;
xa_lock_irq(&inode->i_data.i_pages);
nrpages = inode->i_data.nrpages;
xa_unlock_irq(&inode->i_data.i_pages);
Expand Down

0 comments on commit 55534c0

Please sign in to comment.