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

tty: ipwireless: fix missing checks for ioremap

ipw->attr_memory and ipw->common_memory are assigned with the
return value of ioremap. ioremap may fail, but no checks
are enforced. The fix inserts the checks to avoid potential
NULL pointer dereferences.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Kangjie Lu and committed by
Greg Kroah-Hartman
1bbb1c31 cf90c06f

+8
+8
drivers/tty/ipwireless/main.c
··· 114 114 115 115 ipw->common_memory = ioremap(p_dev->resource[2]->start, 116 116 resource_size(p_dev->resource[2])); 117 + if (!ipw->common_memory) { 118 + ret = -ENOMEM; 119 + goto exit1; 120 + } 117 121 if (!request_mem_region(p_dev->resource[2]->start, 118 122 resource_size(p_dev->resource[2]), 119 123 IPWIRELESS_PCCARD_NAME)) { ··· 138 134 139 135 ipw->attr_memory = ioremap(p_dev->resource[3]->start, 140 136 resource_size(p_dev->resource[3])); 137 + if (!ipw->attr_memory) { 138 + ret = -ENOMEM; 139 + goto exit3; 140 + } 141 141 if (!request_mem_region(p_dev->resource[3]->start, 142 142 resource_size(p_dev->resource[3]), 143 143 IPWIRELESS_PCCARD_NAME)) {