summaryrefslogtreecommitdiffstats
path: root/fs/fat
diff options
context:
space:
mode:
authorOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>2011-04-12 21:08:38 +0900
committerOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>2011-04-12 21:12:16 +0900
commit700309295551ef9217e4ae00a5b1d3030fc5438c (patch)
tree8af7a3eb476cac451183caae636cf3d144e1859d /fs/fat
parent384f5c96ea05aba24a11172ebd6f5d427ca199fc (diff)
downloadlinux-700309295551ef9217e4ae00a5b1d3030fc5438c.tar.gz
linux-700309295551ef9217e4ae00a5b1d3030fc5438c.tar.bz2
linux-700309295551ef9217e4ae00a5b1d3030fc5438c.zip
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>
Diffstat (limited to 'fs/fat')
-rw-r--r--fs/fat/cache.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/fat/cache.c b/fs/fat/cache.c
index ae8200f84e39..1cc7038e273d 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) {