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")
Signed-off-by: Ethan Tidmore <[email protected]>
---
 drivers/gpu/drm/kmb/kmb_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/kmb/kmb_drv.c b/drivers/gpu/drm/kmb/kmb_drv.c
index 7c2eb1152fc2..9eabbce7574f 100644
--- a/drivers/gpu/drm/kmb/kmb_drv.c
+++ b/drivers/gpu/drm/kmb/kmb_drv.c
@@ -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;
 }
-- 
2.53.0

Reply via email to