Skip to content

Commit

Permalink
fscache_cookie_enabled: check cookie is valid before accessing it
Browse files Browse the repository at this point in the history
fscache_cookie_enabled() could be called on NULL cookies and cause a
null pointer dereference when accessing cookie flags: just make sure
the cookie is valid first

Suggested-by: David Howells <[email protected]>
Acked-by: David Howells <[email protected]>
Signed-off-by: Dominique Martinet <[email protected]>
  • Loading branch information
martinetd committed Nov 3, 2021
1 parent 4cd82a5 commit 0dc54bd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/linux/fscache.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ struct fscache_cookie {

static inline bool fscache_cookie_enabled(struct fscache_cookie *cookie)
{
return test_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags);
return fscache_cookie_valid(cookie) && test_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags);
}

/*
Expand Down

0 comments on commit 0dc54bd

Please sign in to comment.