video: hgafb: fix potential NULL pointer dereference
authorKangjie Lu <kjlu@umn.edu>
Mon, 1 Apr 2019 15:46:58 +0000 (17:46 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 15 Jun 2019 09:54:10 +0000 (11:54 +0200)
[ Upstream commit ec7f6aad57ad29e4e66cc2e18e1e1599ddb02542 ]

When ioremap fails, hga_vram should not be dereferenced. The fix
check the failure to avoid NULL pointer dereference.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Cc: Aditya Pakki <pakki001@umn.edu>
Cc: Ferenc Bakonyi <fero@drama.obuda.kando.hu>
[b.zolnierkie: minor patch summary fixup]
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/video/fbdev/hgafb.c

index 4630285..59e1cae 100644 (file)
@@ -285,6 +285,8 @@ static int hga_card_detect(void)
        hga_vram_len  = 0x08000;
 
        hga_vram = ioremap(0xb0000, hga_vram_len);
+       if (!hga_vram)
+               goto error;
 
        if (request_region(0x3b0, 12, "hgafb"))
                release_io_ports = 1;