layerscape: add 64b/32b target for ls1012ardb device
[openwrt/openwrt.git] / target / linux / layerscape / patches-4.4 / 1080-mtd-fsl-quadspi-possible-NULL-dereference.patch
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
5
6 It is theoretically possible to probe this driver without a matching
7 device tree, so let's guard against this.
8
9 Also, use the of_device_get_match_data() helper to make this a bit
10 simpler.
11
12 Coverity complained about this one.
13
14 Signed-off-by: Brian Norris <computersforpeace@gmail.com>
15 Acked-by: Han xu <han.xu@freescale.com>
16 ---
17 drivers/mtd/spi-nor/fsl-quadspi.c | 8 ++++----
18 1 file changed, 4 insertions(+), 4 deletions(-)
19
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;
24 struct device *dev;
25 struct completion c;
26 - struct fsl_qspi_devtype_data *devtype_data;
27 + const struct fsl_qspi_devtype_data *devtype_data;
28 u32 nor_size;
29 u32 nor_num;
30 u32 clk_rate;
31 @@ -933,8 +933,6 @@ static int fsl_qspi_probe(struct platfor
32 struct spi_nor *nor;
33 struct mtd_info *mtd;
34 int ret, i = 0;
35 - const struct of_device_id *of_id =
36 - of_match_device(fsl_qspi_dt_ids, &pdev->dev);
37
38 q = devm_kzalloc(dev, sizeof(*q), GFP_KERNEL);
39 if (!q)
40 @@ -945,7 +943,9 @@ static int fsl_qspi_probe(struct platfor
41 return -ENODEV;
42
43 q->dev = dev;
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)
47 + return -ENODEV;
48 platform_set_drvdata(pdev, q);
49
50 /* find the resources */