Unverified Commit 7e9c7a87 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!8416 iio: adc: stm32-adc: harden against NULL pointer deref in stm32_adc_probe()

parents 3bff6bb7 90319f1c
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -635,6 +635,8 @@ static int stm32_adc_probe(struct platform_device *pdev)
	struct stm32_adc_priv *priv;
	struct device *dev = &pdev->dev;
	struct device_node *np = pdev->dev.of_node;
	const struct of_device_id *of_id;

	struct resource *res;
	u32 max_rate;
	int ret;
@@ -647,8 +649,11 @@ static int stm32_adc_probe(struct platform_device *pdev)
		return -ENOMEM;
	platform_set_drvdata(pdev, &priv->common);

	priv->cfg = (const struct stm32_adc_priv_cfg *)
		of_match_device(dev->driver->of_match_table, dev)->data;
	of_id = of_match_device(dev->driver->of_match_table, dev);
	if (!of_id)
		return -ENODEV;

	priv->cfg = (const struct stm32_adc_priv_cfg *)of_id->data;

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	priv->common.base = devm_ioremap_resource(&pdev->dev, res);