mirror of
https://github.com/hardkernel/linux.git
synced 2026-03-25 20:10:23 +09:00
UPSTREAM: squashfs: fix buffer release race condition in readahead code
Fix a buffer release race condition, where the error value was used after release. Link: https://lkml.kernel.org/r/20221020223616.7571-4-phillip@squashfs.org.uk Fixes:b09a7a036d("squashfs: support reading fragments in readahead call") Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk> Tested-by: Bagas Sanjaya <bagasdotme@gmail.com> Reported-by: Marc Miltenberger <marcmiltenberger@gmail.com> Cc: Dimitri John Ledkov <dimitri.ledkov@canonical.com> Cc: Hsin-Yi Wang <hsinyi@chromium.org> Cc: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr> Cc: Slade Watkins <srw@sladewatkins.net> Cc: Thorsten Leemhuis <regressions@leemhuis.info> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Bug: 290900323 (cherry picked from commite11c4e088b) Change-Id: I9afd4abbfd8a50910670ba7a327aa0d825856560 Signed-off-by: Lecopzer Chen <lecopzer.chen@mediatek.com>
This commit is contained in:
committed by
Lecopzer Chen
parent
813c3dec23
commit
9d4be29185
@@ -504,8 +504,9 @@ static int squashfs_readahead_fragment(struct page **page,
|
||||
squashfs_i(inode)->fragment_size);
|
||||
struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
|
||||
unsigned int n, mask = (1 << (msblk->block_log - PAGE_SHIFT)) - 1;
|
||||
int error = buffer->error;
|
||||
|
||||
if (buffer->error)
|
||||
if (error)
|
||||
goto out;
|
||||
|
||||
expected += squashfs_i(inode)->fragment_offset;
|
||||
@@ -527,7 +528,7 @@ static int squashfs_readahead_fragment(struct page **page,
|
||||
|
||||
out:
|
||||
squashfs_cache_put(buffer);
|
||||
return buffer->error;
|
||||
return error;
|
||||
}
|
||||
|
||||
static void squashfs_readahead(struct readahead_control *ractl)
|
||||
|
||||
Reference in New Issue
Block a user