From 700309295551ef9217e4ae00a5b1d3030fc5438c Mon Sep 17 00:00:00 2001 From: OGAWA Hirofumi Date: Tue, 12 Apr 2011 21:08:38 +0900 Subject: fat: Fix possible null deref in fat_cache_add() Reported-by: Signed-off-by: OGAWA Hirofumi diff --git a/fs/fat/cache.c b/fs/fat/cache.c index ae8200f..1cc7038 100644 --- a/fs/fat/cache.c +++ b/fs/fat/cache.c @@ -151,6 +151,13 @@ static void fat_cache_add(struct inode *inode, struct fat_cache_id *new) spin_unlock(&MSDOS_I(inode)->cache_lru_lock); tmp = fat_cache_alloc(inode); + if (!tmp) { + spin_lock(&MSDOS_I(inode)->cache_lru_lock); + MSDOS_I(inode)->nr_caches--; + spin_unlock(&MSDOS_I(inode)->cache_lru_lock); + return; + } + spin_lock(&MSDOS_I(inode)->cache_lru_lock); cache = fat_cache_merge(inode, new); if (cache != NULL) { -- cgit v0.10.2