mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-04 12:16:41 +00:00
udf: Fold udf_getblk() into udf_bread()
commit32f123a3f3
upstream. udf_getblk() has a single call site. Fold it there. Signed-off-by: Jan Kara <jack@suse.cz> [acsjakub: backport-adjusting changes udf_getblk() has changed between 6.1 and the backported commit, namely in commit541e047b14
("udf: Use udf_map_block() in udf_getblk()") Backport using the form of udf_getblk present in 6.1., that means use udf_get_block() instead of udf_map_block() and use dummy in buffer_new() and buffer_mapped(). ] Closes: https://syzkaller.appspot.com/bug?extid=a38e34ca637c224f4a79 Signed-off-by: Jakub Acs <acsjakub@amazon.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
97c22fd510
commit
eed8395d94
@ -369,29 +369,6 @@ static int udf_get_block(struct inode *inode, sector_t block,
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct buffer_head *udf_getblk(struct inode *inode, udf_pblk_t block,
|
|
||||||
int create, int *err)
|
|
||||||
{
|
|
||||||
struct buffer_head *bh;
|
|
||||||
struct buffer_head dummy;
|
|
||||||
|
|
||||||
dummy.b_state = 0;
|
|
||||||
dummy.b_blocknr = -1000;
|
|
||||||
*err = udf_get_block(inode, block, &dummy, create);
|
|
||||||
if (!*err && buffer_mapped(&dummy)) {
|
|
||||||
bh = sb_getblk(inode->i_sb, dummy.b_blocknr);
|
|
||||||
if (buffer_new(&dummy)) {
|
|
||||||
lock_buffer(bh);
|
|
||||||
memset(bh->b_data, 0x00, inode->i_sb->s_blocksize);
|
|
||||||
set_buffer_uptodate(bh);
|
|
||||||
unlock_buffer(bh);
|
|
||||||
mark_buffer_dirty_inode(bh, inode);
|
|
||||||
}
|
|
||||||
return bh;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Extend the file with new blocks totaling 'new_block_bytes',
|
/* Extend the file with new blocks totaling 'new_block_bytes',
|
||||||
* return the number of extents added
|
* return the number of extents added
|
||||||
@ -1108,11 +1085,30 @@ struct buffer_head *udf_bread(struct inode *inode, udf_pblk_t block,
|
|||||||
int create, int *err)
|
int create, int *err)
|
||||||
{
|
{
|
||||||
struct buffer_head *bh = NULL;
|
struct buffer_head *bh = NULL;
|
||||||
|
struct buffer_head dummy;
|
||||||
|
|
||||||
bh = udf_getblk(inode, block, create, err);
|
dummy.b_state = 0;
|
||||||
if (!bh)
|
dummy.b_blocknr = -1000;
|
||||||
|
|
||||||
|
*err = udf_get_block(inode, block, &dummy, create);
|
||||||
|
if (*err || !buffer_mapped(&dummy))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
bh = sb_getblk(inode->i_sb, dummy.b_blocknr);
|
||||||
|
if (!bh) {
|
||||||
|
*err = -ENOMEM;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buffer_new(&dummy)) {
|
||||||
|
lock_buffer(bh);
|
||||||
|
memset(bh->b_data, 0x00, inode->i_sb->s_blocksize);
|
||||||
|
set_buffer_uptodate(bh);
|
||||||
|
unlock_buffer(bh);
|
||||||
|
mark_buffer_dirty_inode(bh, inode);
|
||||||
|
return bh;
|
||||||
|
}
|
||||||
|
|
||||||
if (bh_read(bh, 0) >= 0)
|
if (bh_read(bh, 0) >= 0)
|
||||||
return bh;
|
return bh;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user