From: Colin Ian King Date: Fri, 30 Aug 2019 17:50:50 +0000 (+0100) Subject: staging: exfat: check for null return from call to FAT_getblk X-Git-Tag: v5.4-rc1~134^2~65 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dab8fe7ea267711cf28bb7c87361fa3c2293fa97;p=platform%2Fkernel%2Flinux-rpi.git staging: exfat: check for null return from call to FAT_getblk A call to FAT_getblk is missing a null return check which can lead to a null pointer dereference. Fix this by adding a null check to match all the other FAT_getblk return sanity checks. Addresses-Coverity: ("Dereference null return") Fixes: c48c9f7ff32b ("staging: exfat: add exfat filesystem code to staging") Signed-off-by: Colin Ian King Link: https://lore.kernel.org/r/20190830175050.12706-1-colin.king@canonical.com Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/exfat/exfat_cache.c b/drivers/staging/exfat/exfat_cache.c index f05d692..1565ce6 100644 --- a/drivers/staging/exfat/exfat_cache.c +++ b/drivers/staging/exfat/exfat_cache.c @@ -369,6 +369,8 @@ static s32 __FAT_write(struct super_block *sb, u32 loc, u32 content) FAT_modify(sb, sec); fat_sector = FAT_getblk(sb, ++sec); + if (!fat_sector) + return -1; fat_sector[0] = (u8)((fat_sector[0] & 0xF0) | (content >> 8)); } else {