LF-1444 gpu: imx: dpu: common: Check of_match_device() return value in dpu_probe()

It would be good to check of_match_device() return value in dpu_probe()
in case it returns a NULL pointer.  This may avoid NULL pointer dereference
from happening.

Signed-off-by: Liu Ying <victor.liu@nxp.com>
Reviewed-by: Sandor Yu <sandor.yu@nxp.com>
This commit is contained in:
Liu Ying
2020-06-03 10:22:26 +08:00
committed by Dong Aisheng
parent 2d71ff1c3e
commit edf3cfdaf9

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2016 Freescale Semiconductor, Inc.
* Copyright 2017-2019 NXP
* Copyright 2017-2020 NXP
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@ -1085,15 +1085,20 @@ err_get_plane_res:
static int dpu_probe(struct platform_device *pdev)
{
const struct of_device_id *of_id =
of_match_device(dpu_dt_ids, &pdev->dev);
const struct of_device_id *of_id;
struct device_node *np = pdev->dev.of_node;
struct dpu_soc *dpu;
struct resource *res;
unsigned long dpu_base;
const struct dpu_data *data = of_id->data;
const struct dpu_data *data;
int ret;
of_id = of_match_device(dpu_dt_ids, &pdev->dev);
if (!of_id)
return -ENODEV;
data = of_id->data;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res)
return -ENODEV;