diff mbox

spi: fsl-spi: fix devm_ioremap_resource() error case

Message ID 20150423121147.AFEA31A2439@localhost.localdomain (mailing list archive)
State Accepted
Commit 73ee39a4c944a11cfd6d43ba1f634da340bf5537
Headers show

Commit Message

Christophe Leroy April 23, 2015, 12:11 p.m. UTC
devm_ioremap_resource() doesn't return NULL but an ERR_PTR on error.

Reported-by: Jonas Gorsky <jogo@openwrt.org>
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>

---
 drivers/spi/spi-fsl-cpm.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Mark Brown April 24, 2015, 12:38 p.m. UTC | #1
On Thu, Apr 23, 2015 at 02:11:47PM +0200, Christophe Leroy wrote:
> devm_ioremap_resource() doesn't return NULL but an ERR_PTR on error.

Applied, thanks.
diff mbox

Patch

diff --git a/drivers/spi/spi-fsl-cpm.c b/drivers/spi/spi-fsl-cpm.c
index 4e5c945..1e66644 100644
--- a/drivers/spi/spi-fsl-cpm.c
+++ b/drivers/spi/spi-fsl-cpm.c
@@ -305,10 +305,15 @@  int fsl_spi_cpm_init(struct mpc8xxx_spi *mspi)
 
 	if (mspi->flags & SPI_CPM1) {
 		struct resource *res;
+		void *pram;
 
 		res = platform_get_resource(to_platform_device(dev),
 					    IORESOURCE_MEM, 1);
-		mspi->pram = devm_ioremap_resource(dev, res);
+		pram = devm_ioremap_resource(dev, res);
+		if (IS_ERR(pram))
+			mspi->pram = NULL;
+		else
+			mspi->pram = pram;
 	} else {
 		unsigned long pram_ofs = fsl_spi_cpm_get_pram(mspi);