1 From bd02decd1ad7cc883ce388e769a34a3c402b90c4 Mon Sep 17 00:00:00 2001
2 From: Brian Norris <computersforpeace@gmail.com>
3 Date: Mon, 16 Nov 2015 10:45:30 -0800
4 Subject: [PATCH 080/113] mtd: fsl-quadspi: possible NULL dereference
6 It is theoretically possible to probe this driver without a matching
7 device tree, so let's guard against this.
9 Also, use the of_device_get_match_data() helper to make this a bit
12 Coverity complained about this one.
14 Signed-off-by: Brian Norris <computersforpeace@gmail.com>
15 Acked-by: Han xu <han.xu@freescale.com>
17 drivers/mtd/spi-nor/fsl-quadspi.c | 8 ++++----
18 1 file changed, 4 insertions(+), 4 deletions(-)
20 --- a/drivers/mtd/spi-nor/fsl-quadspi.c
21 +++ b/drivers/mtd/spi-nor/fsl-quadspi.c
22 @@ -269,7 +269,7 @@ struct fsl_qspi {
23 struct clk *clk, *clk_en;
26 - struct fsl_qspi_devtype_data *devtype_data;
27 + const struct fsl_qspi_devtype_data *devtype_data;
31 @@ -933,8 +933,6 @@ static int fsl_qspi_probe(struct platfor
35 - const struct of_device_id *of_id =
36 - of_match_device(fsl_qspi_dt_ids, &pdev->dev);
38 q = devm_kzalloc(dev, sizeof(*q), GFP_KERNEL);
40 @@ -945,7 +943,9 @@ static int fsl_qspi_probe(struct platfor
44 - q->devtype_data = (struct fsl_qspi_devtype_data *)of_id->data;
45 + q->devtype_data = of_device_get_match_data(dev);
46 + if (!q->devtype_data)
48 platform_set_drvdata(pdev, q);
50 /* find the resources */