Skip to content

Commit 7003092

Browse files
committed
fat: Fix possible null deref in fat_cache_add()
Reported-by: <dame_eugene@mail.ru> Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
1 parent 384f5c9 commit 7003092

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎fs/fat/cache.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,13 @@ static void fat_cache_add(struct inode *inode, struct fat_cache_id *new)
151151
spin_unlock(&MSDOS_I(inode)->cache_lru_lock);
152152

153153
tmp = fat_cache_alloc(inode);
154+
if (!tmp) {
155+
spin_lock(&MSDOS_I(inode)->cache_lru_lock);
156+
MSDOS_I(inode)->nr_caches--;
157+
spin_unlock(&MSDOS_I(inode)->cache_lru_lock);
158+
return;
159+
}
160+
154161
spin_lock(&MSDOS_I(inode)->cache_lru_lock);
155162
cache = fat_cache_merge(inode, new);
156163
if (cache != NULL) {

0 commit comments

Comments
 (0)