From: Jean-Michel Hautbois Date: Tue, 5 Aug 2014 16:19:37 +0000 (+0200) Subject: Lattice ECP3 FPGA: Check firmware pointer X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=3f0d97d97f2b539cf9ac746be4ec097259e6a8d0;p=linux-beck.git 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 Reviewed-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/misc/lattice-ecp3-config.c b/drivers/misc/lattice-ecp3-config.c index 7ffdb589841e..7e1efd5f58f0 100644 --- a/drivers/misc/lattice-ecp3-config.c +++ b/drivers/misc/lattice-ecp3-config.c @@ -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;