Skip to contentSkip to conversation

drm/kmb: Fix error pointer dereference

PATCH New Ethan Tidmore 1 participant 1 message Feb 19

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/kmb: Fix error pointer dereference

The function kmb_dsi_init() can return an error pointer and is checked for it, and once confirm here in this code block below, goes to the label err_free1:

kmb->kmb_dsi = kmb_dsi_init(dsi_pdev);

if (IS_ERR(kmb->kmb_dsi)) {
	drm_err(&kmb->drm, "failed to initialize DSI\n");
	ret = PTR_ERR(kmb->kmb_dsi);
	goto err_free1;
}

At the label itself it dereferences the confirmed error pointer.

err_free1:

	dev_set_drvdata(dev, NULL);
	kmb_dsi_host_unregister(kmb->kmb_dsi);

	return ret;
}

Add check for error pointer before running kmb_dsi_host_unregister().

Fixes 7f7b96a8a0a18 ("drm/kmb: Add support for KeemBay Display")
---
 drivers/gpu/drm/kmb/kmb_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/kmb/kmb_drv.c +2 -1
index 7c2eb1152fc2..9eabbce7574f 100644
@@ -576,7 +576,8 @@ static int kmb_probe(struct platform_device *pdev)
 	drm_mode_config_cleanup(&kmb->drm);
  err_free1:
 	dev_set_drvdata(dev, NULL);
-	kmb_dsi_host_unregister(kmb->kmb_dsi);
+	if (!IS_ERR(kmb->kmb_dsi))
+		kmb_dsi_host_unregister(kmb->kmb_dsi);
 
 	return ret;
 }
Signature · 1 line
2.53.0