Lattice ECP3 FPGA: Check firmware pointer

This patch corrects a lack of testing.
If fw is NULL when calling firmware_load(), it results in a kernel oops.

Signed-off-by: Jean-Michel Hautbois <jean-michel.hautbois@vodalys.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Jean-Michel Hautbois 2014-08-05 18:19:37 +02:00 committed by Greg Kroah-Hartman
parent 69e273c0b0
commit 3f0d97d97f
1 changed files with 5 additions and 0 deletions

View File

@ -79,6 +79,11 @@ static void firmware_load(const struct firmware *fw, void *context)
u32 jedec_id;
u32 status;
if (fw == NULL) {
dev_err(&spi->dev, "Cannot load firmware, aborting\n");
return;
}
if (fw->size == 0) {
dev_err(&spi->dev, "Error: Firmware size is 0!\n");
return;