Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1569389

[PATCH] spi - Fix possible NULL derefrence.

From Shailendra Verma <shailendra.v@samsung.com>
Newsgroups linux.kernel
Subject [PATCH] spi - Fix possible NULL derefrence.
Date 2017-01-30 06:00 +0100
Message-ID <t5cem-804-21@gated-at.bofh.it> (permalink)
References <t5cem-804-23@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


of_match_device could return NULL, and so can cause a NULL
pointer dereference later.

Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
---
 drivers/spi/spi-mxs.c |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/spi/spi-mxs.c b/drivers/spi/spi-mxs.c
index 5b0e9a3..c3aea7e 100644
--- a/drivers/spi/spi-mxs.c
+++ b/drivers/spi/spi-mxs.c
@@ -470,6 +470,11 @@ static int mxs_spi_probe(struct platform_device *pdev)
 	 */
 	const int clk_freq_default = 160000000;
 
+	if (!of_id) {
+		dev_err(&pdev->dev, "Error: No device match found\n");
+		return -ENODEV;
+	}
+
 	iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	irq_err = platform_get_irq(pdev, 0);
 	if (irq_err < 0)
-- 
1.7.9.5

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] spi - Fix possible NULL derefrence. Shailendra Verma <shailendra.v@samsung.com> - 2017-01-30 06:00 +0100
  Re: [PATCH] spi - Fix possible NULL derefrence. Geert Uytterhoeven <geert@linux-m68k.org> - 2017-01-30 11:10 +0100
    Re: [PATCH] spi - Fix possible NULL derefrence. Mark Brown <broonie@kernel.org> - 2017-01-30 14:20 +0100

csiph-web