Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1270469 > unrolled thread
| Started by | Brian Norris <computersforpeace@gmail.com> |
|---|---|
| First post | 2015-11-16 19:50 +0100 |
| Last post | 2015-11-18 19:40 +0100 |
| Articles | 3 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH] mtd: fsl-quadspi: possible NULL reference Brian Norris <computersforpeace@gmail.com> - 2015-11-16 19:50 +0100
[PATCH v2] mtd: fsl-quadspi: possible NULL dereference Brian Norris <computersforpeace@gmail.com> - 2015-11-16 19:50 +0100
Re: [PATCH v2] mtd: fsl-quadspi: possible NULL dereference Brian Norris <computersforpeace@gmail.com> - 2015-11-18 19:40 +0100
| From | Brian Norris <computersforpeace@gmail.com> |
|---|---|
| Date | 2015-11-16 19:50 +0100 |
| Subject | [PATCH] mtd: fsl-quadspi: possible NULL reference |
| Message-ID | <qvx0K-2t2-21@gated-at.bofh.it> |
It is theoretically possible to probe this driver without a matching device tree, so let's guard against this. Also, use the of_device_get_match_data() helper to make this a bit simpler. Coverity complained about this one. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Cc: Han Xu <han.xu@freescale.com> --- drivers/mtd/spi-nor/fsl-quadspi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/spi-nor/fsl-quadspi.c b/drivers/mtd/spi-nor/fsl-quadspi.c index cc3a70b9b020..68fe7a2ecd5c 100644 --- a/drivers/mtd/spi-nor/fsl-quadspi.c +++ b/drivers/mtd/spi-nor/fsl-quadspi.c @@ -933,8 +933,6 @@ static int fsl_qspi_probe(struct platform_device *pdev) struct spi_nor *nor; struct mtd_info *mtd; int ret, i = 0; - const struct of_device_id *of_id = - of_match_device(fsl_qspi_dt_ids, &pdev->dev); q = devm_kzalloc(dev, sizeof(*q), GFP_KERNEL); if (!q) @@ -945,7 +943,9 @@ static int fsl_qspi_probe(struct platform_device *pdev) return -ENODEV; q->dev = dev; - q->devtype_data = (struct fsl_qspi_devtype_data *)of_id->data; + q->devtype_data = of_device_get_match_data(dev); + if (!q->devtype_data) + return -ENODEV; platform_set_drvdata(pdev, q); /* find the resources */ -- 2.6.0.rc2.230.g3dd15c0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Brian Norris <computersforpeace@gmail.com> |
|---|---|
| Date | 2015-11-16 19:50 +0100 |
| Subject | [PATCH v2] mtd: fsl-quadspi: possible NULL dereference |
| Message-ID | <qvx0K-2t2-23@gated-at.bofh.it> |
| In reply to | #1270469 |
It is theoretically possible to probe this driver without a matching
device tree, so let's guard against this.
Also, use the of_device_get_match_data() helper to make this a bit
simpler.
Coverity complained about this one.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Cc: Han Xu <han.xu@freescale.com>
---
v2:
* missed a 'const' warning
* s/reference/dereference in $subject
drivers/mtd/spi-nor/fsl-quadspi.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/mtd/spi-nor/fsl-quadspi.c b/drivers/mtd/spi-nor/fsl-quadspi.c
index cc3a70b9b020..916d6dd5b575 100644
--- a/drivers/mtd/spi-nor/fsl-quadspi.c
+++ b/drivers/mtd/spi-nor/fsl-quadspi.c
@@ -269,7 +269,7 @@ struct fsl_qspi {
struct clk *clk, *clk_en;
struct device *dev;
struct completion c;
- struct fsl_qspi_devtype_data *devtype_data;
+ const struct fsl_qspi_devtype_data *devtype_data;
u32 nor_size;
u32 nor_num;
u32 clk_rate;
@@ -933,8 +933,6 @@ static int fsl_qspi_probe(struct platform_device *pdev)
struct spi_nor *nor;
struct mtd_info *mtd;
int ret, i = 0;
- const struct of_device_id *of_id =
- of_match_device(fsl_qspi_dt_ids, &pdev->dev);
q = devm_kzalloc(dev, sizeof(*q), GFP_KERNEL);
if (!q)
@@ -945,7 +943,9 @@ static int fsl_qspi_probe(struct platform_device *pdev)
return -ENODEV;
q->dev = dev;
- q->devtype_data = (struct fsl_qspi_devtype_data *)of_id->data;
+ q->devtype_data = of_device_get_match_data(dev);
+ if (!q->devtype_data)
+ return -ENODEV;
platform_set_drvdata(pdev, q);
/* find the resources */
--
2.6.0.rc2.230.g3dd15c0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Brian Norris <computersforpeace@gmail.com> |
|---|---|
| Date | 2015-11-18 19:40 +0100 |
| Subject | Re: [PATCH v2] mtd: fsl-quadspi: possible NULL dereference |
| Message-ID | <qwfOa-6FW-19@gated-at.bofh.it> |
| In reply to | #1270472 |
On Mon, Nov 16, 2015 at 10:45:30AM -0800, Brian Norris wrote: > It is theoretically possible to probe this driver without a matching > device tree, so let's guard against this. > > Also, use the of_device_get_match_data() helper to make this a bit > simpler. > > Coverity complained about this one. > > Signed-off-by: Brian Norris <computersforpeace@gmail.com> > Cc: Han Xu <han.xu@freescale.com> > --- > v2: > * missed a 'const' warning > * s/reference/dereference in $subject Pushed to l2-mtd.git -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web