From edf3cfdaf99372811ef1fb980f09619cb159acac Mon Sep 17 00:00:00 2001 From: Liu Ying Date: Wed, 3 Jun 2020 10:22:26 +0800 Subject: [PATCH] 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 Reviewed-by: Sandor Yu --- drivers/gpu/imx/dpu/dpu-common.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/imx/dpu/dpu-common.c b/drivers/gpu/imx/dpu/dpu-common.c index 90cec011c726..1e4de67e032a 100644 --- a/drivers/gpu/imx/dpu/dpu-common.c +++ b/drivers/gpu/imx/dpu/dpu-common.c @@ -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;