Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1568331
| From | Marek Vasut <marek.vasut@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] Mtd: nand - Fix possible NULL derefrence. |
| Date | 2017-01-27 13:40 +0100 |
| Message-ID | <t4dYR-49I-25@gated-at.bofh.it> (permalink) |
| References | <t4cTb-3sv-93@gated-at.bofh.it> <t4cTb-3sv-91@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] Mtd: nand - Fix possible NULL derefrence. Shailendra Verma <shailendra.v@samsung.com> - 2017-01-27 12:30 +0100
Re: [PATCH] Mtd: nand - Fix possible NULL derefrence. Marek Vasut <marek.vasut@gmail.com> - 2017-01-27 13:40 +0100
Re: [PATCH] Mtd: nand - Fix possible NULL derefrence. Boris Brezillon <boris.brezillon@free-electrons.com> - 2017-01-27 15:10 +0100
csiph-web