Skip to content

Commit 0dc54bd

Browse files
committed
fscache_cookie_enabled: check cookie is valid before accessing it
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]>
1 parent 4cd82a5 commit 0dc54bd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/linux/fscache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ struct fscache_cookie {
167167

168168
static inline bool fscache_cookie_enabled(struct fscache_cookie *cookie)
169169
{
170-
return test_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags);
170+
return fscache_cookie_valid(cookie) && test_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags);
171171
}
172172

173173
/*

0 commit comments

Comments
 (0)