USB: emi62: fix crash when trying to load EMI 6|2 firmware
authorClemens Ladisch <clemens@ladisch.de>
Mon, 21 Dec 2009 23:36:44 +0000 (15:36 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 6 Jan 2010 23:03:37 +0000 (15:03 -0800)
commit702a0a0aed69a97f7001c67a652f49934ac7de0d
tree97b925f19135f28c4a1c14319155a1808f432e52
parent2d67231fb86da345be96ba212dfeb4d8c912520b
USB: emi62: fix crash when trying to load EMI 6|2 firmware

commit ac06c06770bb8761b1f1f9bdf2f5420fa6d3e9fa upstream.

While converting emi62 to use request_firmware(), the driver was also
changed to use the ihex helper functions.  However, this broke the loading
of the FPGA firmware because the code tries to access the addr field of
the EOF record which works with a plain array that has an empty last
record but not with the ihex helper functions where the end of the data is
signaled with a NULL record pointer, resulting in:

BUG: unable to handle kernel NULL pointer dereference at (null)
IP: [<f80d248c>] emi62_load_firmware+0x33c/0x740 [emi62]

This can be fixed by changing the loop condition to test the return value
of ihex_next_binrec() directly (like in emi26.c).

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Reported-and-tested-by: Der Mickster <retroeffective@gmail.com>
Acked-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/misc/emi62.c