* [PATCH] Mtd: nand - Fix possible NULL derefrence. [not found] <CGME20170127112921epcas1p45999b22222202e8d98b6aecfc3cbeb39@epcas1p4.samsung.com> @ 2017-01-27 11:29 ` Shailendra Verma 2017-01-27 12:24 ` Marek Vasut 0 siblings, 1 reply; 6+ messages in thread From: Shailendra Verma @ 2017-01-27 11:29 UTC (permalink / raw) To: Boris Brezillon, Richard Weinberger, David Woodhouse, Brian Norris, Marek Vasut, Cyrille Pitchen, linux-mtd, linux-kernel, p.shailesh, ashish.kalra, Shailendra Verma, Shailendra Verma 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/mtd/nand/mxc_nand.c | 4 ++++ drivers/mtd/nand/vf610_nfc.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c index d7f724b..ca1b8ad 100644 --- a/drivers/mtd/nand/mxc_nand.c +++ b/drivers/mtd/nand/mxc_nand.c @@ -1596,6 +1596,10 @@ static int __init mxcnd_probe_dt(struct mxc_nand_host *host) if (!np) return 1; + if (!of_id) { + dev_err(host->dev, "Error: No device match found\n"); + return -ENODEV; + } host->devtype_data = of_id->data; return 0; diff --git a/drivers/mtd/nand/vf610_nfc.c b/drivers/mtd/nand/vf610_nfc.c index 3ad514c..0e09c11 100644 --- a/drivers/mtd/nand/vf610_nfc.c +++ b/drivers/mtd/nand/vf610_nfc.c @@ -674,6 +674,10 @@ static int vf610_nfc_probe(struct platform_device *pdev) } of_id = of_match_device(vf610_nfc_dt_ids, &pdev->dev); + if (!of_id) { + dev_err(&pdev->dev, "Error: No device match found\n"); + return -ENODEV; + } nfc->variant = (enum vf610_nfc_variant)of_id->data; for_each_available_child_of_node(nfc->dev->of_node, child) { -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] Mtd: nand - Fix possible NULL derefrence. 2017-01-27 11:29 ` [PATCH] Mtd: nand - Fix possible NULL derefrence Shailendra Verma @ 2017-01-27 12:24 ` Marek Vasut 2017-01-27 12:44 ` Boris Brezillon 0 siblings, 1 reply; 6+ messages in thread From: Marek Vasut @ 2017-01-27 12:24 UTC (permalink / raw) To: Shailendra Verma, Boris Brezillon, Richard Weinberger, David Woodhouse, Brian Norris, Cyrille Pitchen, linux-mtd, linux-kernel, p.shailesh, ashish.kalra, Shailendra Verma On 01/27/2017 12:29 PM, Shailendra Verma wrote: > of_match_device could return NULL, and so can cause a NULL > pointer dereference later. > > Signed-off-by: Shailendra Verma <shailendra.v@samsung.com> Nice find, but can you split this into two patches ? And the prefix is 'mtd' without capital letter. Thanks > --- > drivers/mtd/nand/mxc_nand.c | 4 ++++ > drivers/mtd/nand/vf610_nfc.c | 4 ++++ > 2 files changed, 8 insertions(+) > > diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c > index d7f724b..ca1b8ad 100644 > --- a/drivers/mtd/nand/mxc_nand.c > +++ b/drivers/mtd/nand/mxc_nand.c > @@ -1596,6 +1596,10 @@ static int __init mxcnd_probe_dt(struct mxc_nand_host *host) > if (!np) > return 1; > > + if (!of_id) { > + dev_err(host->dev, "Error: No device match found\n"); > + return -ENODEV; > + } > host->devtype_data = of_id->data; > > return 0; > diff --git a/drivers/mtd/nand/vf610_nfc.c b/drivers/mtd/nand/vf610_nfc.c > index 3ad514c..0e09c11 100644 > --- a/drivers/mtd/nand/vf610_nfc.c > +++ b/drivers/mtd/nand/vf610_nfc.c > @@ -674,6 +674,10 @@ static int vf610_nfc_probe(struct platform_device *pdev) > } > > of_id = of_match_device(vf610_nfc_dt_ids, &pdev->dev); > + if (!of_id) { > + dev_err(&pdev->dev, "Error: No device match found\n"); > + return -ENODEV; > + } > nfc->variant = (enum vf610_nfc_variant)of_id->data; > > for_each_available_child_of_node(nfc->dev->of_node, child) { > -- Best regards, Marek Vasut ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Mtd: nand - Fix possible NULL derefrence. 2017-01-27 12:24 ` Marek Vasut @ 2017-01-27 12:44 ` Boris Brezillon 0 siblings, 0 replies; 6+ messages in thread From: Boris Brezillon @ 2017-01-27 12:44 UTC (permalink / raw) To: Marek Vasut Cc: Shailendra Verma, Richard Weinberger, David Woodhouse, Brian Norris, Cyrille Pitchen, linux-mtd, linux-kernel, p.shailesh, ashish.kalra, Shailendra Verma On Fri, 27 Jan 2017 13:24:18 +0100 Marek Vasut <marek.vasut@gmail.com> wrote: > On 01/27/2017 12:29 PM, Shailendra Verma wrote: > > of_match_device could return NULL, and so can cause a NULL > > pointer dereference later. > > That's a purely hypothetical bug since the core already matched against one of the compatible in the of_match table to decide to attach the device to this driver. Having of_match_device() return NULL here means something went seriously wrong (memory corruption ?). This being said, I'm not strongly opposed to this patch. Just a minor comment below. Thanks, Boris > > Signed-off-by: Shailendra Verma <shailendra.v@samsung.com> > > Nice find, but can you split this into two patches ? And the prefix is > 'mtd' without capital letter. > > Thanks > > > --- > > drivers/mtd/nand/mxc_nand.c | 4 ++++ > > drivers/mtd/nand/vf610_nfc.c | 4 ++++ > > 2 files changed, 8 insertions(+) > > > > diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c > > index d7f724b..ca1b8ad 100644 > > --- a/drivers/mtd/nand/mxc_nand.c > > +++ b/drivers/mtd/nand/mxc_nand.c > > @@ -1596,6 +1596,10 @@ static int __init mxcnd_probe_dt(struct mxc_nand_host *host) > > if (!np) > > return 1; > > > > + if (!of_id) { > > + dev_err(host->dev, "Error: No device match found\n"); > > + return -ENODEV; > > + } Add an empty line here. > > host->devtype_data = of_id->data; > > > > return 0; > > diff --git a/drivers/mtd/nand/vf610_nfc.c b/drivers/mtd/nand/vf610_nfc.c > > index 3ad514c..0e09c11 100644 > > --- a/drivers/mtd/nand/vf610_nfc.c > > +++ b/drivers/mtd/nand/vf610_nfc.c > > @@ -674,6 +674,10 @@ static int vf610_nfc_probe(struct platform_device *pdev) > > } > > > > of_id = of_match_device(vf610_nfc_dt_ids, &pdev->dev); > > + if (!of_id) { > > + dev_err(&pdev->dev, "Error: No device match found\n"); > > + return -ENODEV; > > + } Ditto. > > nfc->variant = (enum vf610_nfc_variant)of_id->data; > > > > for_each_available_child_of_node(nfc->dev->of_node, child) { > > > > ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <CGME20170130044701epcas2p327897c254334e190e982c208de1c034c@epcas2p3.samsung.com>]
* [PATCH] Mtd: nand - Fix possible NULL derefrence. [not found] <CGME20170130044701epcas2p327897c254334e190e982c208de1c034c@epcas2p3.samsung.com> @ 2017-01-30 4:46 ` Shailendra Verma 0 siblings, 0 replies; 6+ messages in thread From: Shailendra Verma @ 2017-01-30 4:46 UTC (permalink / raw) To: Boris Brezillon, Richard Weinberger, David Woodhouse, Brian Norris, Marek Vasut, Cyrille Pitchen, linux-mtd, linux-kernel, p.shailesh, ashish.kalra, Shailendra Verma, Shailendra Verma 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/mtd/nand/mxc_nand.c | 4 ++++ drivers/mtd/nand/vf610_nfc.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c index d7f724b..ca1b8ad 100644 --- a/drivers/mtd/nand/mxc_nand.c +++ b/drivers/mtd/nand/mxc_nand.c @@ -1596,6 +1596,10 @@ static int __init mxcnd_probe_dt(struct mxc_nand_host *host) if (!np) return 1; + if (!of_id) { + dev_err(host->dev, "Error: No device match found\n"); + return -ENODEV; + } host->devtype_data = of_id->data; return 0; diff --git a/drivers/mtd/nand/vf610_nfc.c b/drivers/mtd/nand/vf610_nfc.c index 3ad514c..0e09c11 100644 --- a/drivers/mtd/nand/vf610_nfc.c +++ b/drivers/mtd/nand/vf610_nfc.c @@ -674,6 +674,10 @@ static int vf610_nfc_probe(struct platform_device *pdev) } of_id = of_match_device(vf610_nfc_dt_ids, &pdev->dev); + if (!of_id) { + dev_err(&pdev->dev, "Error: No device match found\n"); + return -ENODEV; + } nfc->variant = (enum vf610_nfc_variant)of_id->data; for_each_available_child_of_node(nfc->dev->of_node, child) { -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 6+ messages in thread
[parent not found: <CGME20170130045947epcas4p48c244819af3cad2c5f1f8120192611d2@epcas4p4.samsung.com>]
* [PATCH] Mtd: nand - Fix possible NULL derefrence. [not found] <CGME20170130045947epcas4p48c244819af3cad2c5f1f8120192611d2@epcas4p4.samsung.com> @ 2017-01-30 4:59 ` Shailendra Verma 2017-01-30 7:56 ` Boris Brezillon 0 siblings, 1 reply; 6+ messages in thread From: Shailendra Verma @ 2017-01-30 4:59 UTC (permalink / raw) To: Boris Brezillon, Richard Weinberger, David Woodhouse, Brian Norris, Marek Vasut, Cyrille Pitchen, Stefan Agner, linux-mtd, linux-kernel, p.shailesh, ashish.kalra, Shailendra Verma, Shailendra Verma 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/mtd/nand/mxc_nand.c | 4 ++++ drivers/mtd/nand/vf610_nfc.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c index d7f724b..ca1b8ad 100644 --- a/drivers/mtd/nand/mxc_nand.c +++ b/drivers/mtd/nand/mxc_nand.c @@ -1596,6 +1596,10 @@ static int __init mxcnd_probe_dt(struct mxc_nand_host *host) if (!np) return 1; + if (!of_id) { + dev_err(host->dev, "Error: No device match found\n"); + return -ENODEV; + } host->devtype_data = of_id->data; return 0; diff --git a/drivers/mtd/nand/vf610_nfc.c b/drivers/mtd/nand/vf610_nfc.c index 3ad514c..0e09c11 100644 --- a/drivers/mtd/nand/vf610_nfc.c +++ b/drivers/mtd/nand/vf610_nfc.c @@ -674,6 +674,10 @@ static int vf610_nfc_probe(struct platform_device *pdev) } of_id = of_match_device(vf610_nfc_dt_ids, &pdev->dev); + if (!of_id) { + dev_err(&pdev->dev, "Error: No device match found\n"); + return -ENODEV; + } nfc->variant = (enum vf610_nfc_variant)of_id->data; for_each_available_child_of_node(nfc->dev->of_node, child) { -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] Mtd: nand - Fix possible NULL derefrence. 2017-01-30 4:59 ` Shailendra Verma @ 2017-01-30 7:56 ` Boris Brezillon 0 siblings, 0 replies; 6+ messages in thread From: Boris Brezillon @ 2017-01-30 7:56 UTC (permalink / raw) To: Shailendra Verma Cc: Richard Weinberger, David Woodhouse, Brian Norris, Marek Vasut, Cyrille Pitchen, Stefan Agner, linux-mtd, linux-kernel, p.shailesh, ashish.kalra, Shailendra Verma Hi Shailendra, Marek and I already reviewed this patch, and you're resending it without any of the comments addressed. Is this a mistake? On Mon, 30 Jan 2017 10:29:17 +0530 Shailendra Verma <shailendra.v@samsung.com> wrote: > 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/mtd/nand/mxc_nand.c | 4 ++++ > drivers/mtd/nand/vf610_nfc.c | 4 ++++ > 2 files changed, 8 insertions(+) > > diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c > index d7f724b..ca1b8ad 100644 > --- a/drivers/mtd/nand/mxc_nand.c > +++ b/drivers/mtd/nand/mxc_nand.c > @@ -1596,6 +1596,10 @@ static int __init mxcnd_probe_dt(struct mxc_nand_host *host) > if (!np) > return 1; > > + if (!of_id) { > + dev_err(host->dev, "Error: No device match found\n"); > + return -ENODEV; > + } > host->devtype_data = of_id->data; > > return 0; > diff --git a/drivers/mtd/nand/vf610_nfc.c b/drivers/mtd/nand/vf610_nfc.c > index 3ad514c..0e09c11 100644 > --- a/drivers/mtd/nand/vf610_nfc.c > +++ b/drivers/mtd/nand/vf610_nfc.c > @@ -674,6 +674,10 @@ static int vf610_nfc_probe(struct platform_device *pdev) > } > > of_id = of_match_device(vf610_nfc_dt_ids, &pdev->dev); > + if (!of_id) { > + dev_err(&pdev->dev, "Error: No device match found\n"); > + return -ENODEV; > + } > nfc->variant = (enum vf610_nfc_variant)of_id->data; > > for_each_available_child_of_node(nfc->dev->of_node, child) { ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-01-30 8:07 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <CGME20170127112921epcas1p45999b22222202e8d98b6aecfc3cbeb39@epcas1p4.samsung.com> 2017-01-27 11:29 ` [PATCH] Mtd: nand - Fix possible NULL derefrence Shailendra Verma 2017-01-27 12:24 ` Marek Vasut 2017-01-27 12:44 ` Boris Brezillon [not found] <CGME20170130044701epcas2p327897c254334e190e982c208de1c034c@epcas2p3.samsung.com> 2017-01-30 4:46 ` Shailendra Verma [not found] <CGME20170130045947epcas4p48c244819af3cad2c5f1f8120192611d2@epcas4p4.samsung.com> 2017-01-30 4:59 ` Shailendra Verma 2017-01-30 7:56 ` Boris Brezillon
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.