Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 371566f6 authored by Arturo Giusti's avatar Arturo Giusti Committed by Greg Kroah-Hartman
Browse files

udf: Fix NULL pointer dereference in udf_symlink function

[ Upstream commit fa236c2b2d4436d9f19ee4e5d5924e90ffd7bb43 ]

In function udf_symlink, epos.bh is assigned with the value returned
by udf_tgetblk. The function udf_tgetblk is defined in udf/misc.c
and returns the value of sb_getblk function that could be NULL.
Then, epos.bh is used without any check, causing a possible
NULL pointer dereference when sb_getblk fails.

This fix adds a check to validate the value of epos.bh.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=213083


Signed-off-by: default avatarArturo Giusti <koredump@protonmail.com>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 51a37e9f
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -956,6 +956,10 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
				iinfo->i_location.partitionReferenceNum,
				iinfo->i_location.partitionReferenceNum,
				0);
				0);
		epos.bh = udf_tgetblk(sb, block);
		epos.bh = udf_tgetblk(sb, block);
		if (unlikely(!epos.bh)) {
			err = -ENOMEM;
			goto out_no_entry;
		}
		lock_buffer(epos.bh);
		lock_buffer(epos.bh);
		memset(epos.bh->b_data, 0x00, bsize);
		memset(epos.bh->b_data, 0x00, bsize);
		set_buffer_uptodate(epos.bh);
		set_buffer_uptodate(epos.bh);