Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

video: fbdev: w100fb: Reset global state

w100fb_probe() did not reset the global state to its initial state. This
can result in invocation of iounmap() even when there was not the
appropriate successful call of ioremap(). For instance, this may be the
case if first probe fails after two successful ioremap() while second
probe fails when first ioremap() fails. The similar issue is with
w100fb_remove(). The patch fixes both bugs.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Evgeny Novikov <novikov@ispras.ru>
Co-developed-by: Kirill Shilimanov <kirill.shilimanov@huawei.com>
Signed-off-by: Kirill Shilimanov <kirill.shilimanov@huawei.com>
Signed-off-by: Helge Deller <deller@gmx.de>

authored by

Evgeny Novikov and committed by
Helge Deller
8738ddca 212efde8

+12 -3
+12 -3
drivers/video/fbdev/w100fb.c
··· 770 770 fb_dealloc_cmap(&info->cmap); 771 771 kfree(info->pseudo_palette); 772 772 } 773 - if (remapped_fbuf != NULL) 773 + if (remapped_fbuf != NULL) { 774 774 iounmap(remapped_fbuf); 775 - if (remapped_regs != NULL) 775 + remapped_fbuf = NULL; 776 + } 777 + if (remapped_regs != NULL) { 776 778 iounmap(remapped_regs); 777 - if (remapped_base != NULL) 779 + remapped_regs = NULL; 780 + } 781 + if (remapped_base != NULL) { 778 782 iounmap(remapped_base); 783 + remapped_base = NULL; 784 + } 779 785 if (info) 780 786 framebuffer_release(info); 781 787 return err; ··· 801 795 fb_dealloc_cmap(&info->cmap); 802 796 803 797 iounmap(remapped_base); 798 + remapped_base = NULL; 804 799 iounmap(remapped_regs); 800 + remapped_regs = NULL; 805 801 iounmap(remapped_fbuf); 802 + remapped_fbuf = NULL; 806 803 807 804 framebuffer_release(info); 808 805