Skip to content

Commit

Permalink
Merge tag 'erofs-for-5.8-rc3-fixes' of git://git.kernel.org/pub/scm/l…
Browse files Browse the repository at this point in the history
…inux/kernel/git/xiang/erofs

Pull erofs fix from Gao Xiang:
 "Fix a regression which uses potential uninitialized high 32-bit value
  unexpectedly recently observed with specific compiler options"

* tag 'erofs-for-5.8-rc3-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs:
  erofs: fix partially uninitialized misuse in z_erofs_onlinepage_fixup
  • Loading branch information
torvalds committed Jun 25, 2020
2 parents fc10807 + 3c59728 commit 8be3a53
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions fs/erofs/zdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,22 +144,22 @@ static inline void z_erofs_onlinepage_init(struct page *page)
static inline void z_erofs_onlinepage_fixup(struct page *page,
uintptr_t index, bool down)
{
unsigned long *p, o, v, id;
repeat:
p = &page_private(page);
o = READ_ONCE(*p);
union z_erofs_onlinepage_converter u = { .v = &page_private(page) };
int orig, orig_index, val;

id = o >> Z_EROFS_ONLINEPAGE_INDEX_SHIFT;
if (id) {
repeat:
orig = atomic_read(u.o);
orig_index = orig >> Z_EROFS_ONLINEPAGE_INDEX_SHIFT;
if (orig_index) {
if (!index)
return;

DBG_BUGON(id != index);
DBG_BUGON(orig_index != index);
}

v = (index << Z_EROFS_ONLINEPAGE_INDEX_SHIFT) |
((o & Z_EROFS_ONLINEPAGE_COUNT_MASK) + (unsigned int)down);
if (cmpxchg(p, o, v) != o)
val = (index << Z_EROFS_ONLINEPAGE_INDEX_SHIFT) |
((orig & Z_EROFS_ONLINEPAGE_COUNT_MASK) + (unsigned int)down);
if (atomic_cmpxchg(u.o, orig, val) != orig)
goto repeat;
}

Expand Down

0 comments on commit 8be3a53

Please sign in to comment.