|
Takashi Iwai |
18259a |
From 5620b135aea49a8f41c86aaecfcb1598a7774121 Mon Sep 17 00:00:00 2001
|
|
Takashi Iwai |
18259a |
From: Stephen Boyd <swboyd@chromium.org>
|
|
Takashi Iwai |
18259a |
Date: Thu, 25 Mar 2021 14:28:22 -0700
|
|
Takashi Iwai |
18259a |
Subject: [PATCH] drm/msm: Set drvdata to NULL when msm_drm_init() fails
|
|
Takashi Iwai |
18259a |
Git-commit: 5620b135aea49a8f41c86aaecfcb1598a7774121
|
|
Takashi Iwai |
18259a |
Patch-mainline: v5.12-rc7
|
|
Takashi Iwai |
18259a |
References: git-fixes
|
|
Takashi Iwai |
18259a |
|
|
Takashi Iwai |
18259a |
We should set the platform device's driver data to NULL here so that
|
|
Takashi Iwai |
18259a |
code doesn't assume the struct drm_device pointer is valid when it could
|
|
Takashi Iwai |
18259a |
have been destroyed. The lifetime of this pointer is managed by a kref
|
|
Takashi Iwai |
18259a |
but when msm_drm_init() fails we call drm_dev_put() on the pointer which
|
|
Takashi Iwai |
18259a |
will free the pointer's memory. This driver uses the component model, so
|
|
Takashi Iwai |
18259a |
there's sort of two "probes" in this file, one for the platform device
|
|
Takashi Iwai |
18259a |
i.e. msm_pdev_probe() and one for the component i.e. msm_drm_bind(). The
|
|
Takashi Iwai |
18259a |
msm_drm_bind() code is using the platform device's driver data to store
|
|
Takashi Iwai |
18259a |
struct drm_device so the two functions are intertwined.
|
|
Takashi Iwai |
18259a |
|
|
Takashi Iwai |
18259a |
This relationship becomes a problem for msm_pdev_shutdown() when it
|
|
Takashi Iwai |
18259a |
tests the NULL-ness of the pointer to see if it should call
|
|
Takashi Iwai |
18259a |
drm_atomic_helper_shutdown(). The NULL test is a proxy check for if the
|
|
Takashi Iwai |
18259a |
pointer has been freed by kref_put(). If the drm_device has been
|
|
Takashi Iwai |
18259a |
destroyed, then we shouldn't call the shutdown helper, and we know that
|
|
Takashi Iwai |
18259a |
is the case if msm_drm_init() failed, therefore set the driver data to
|
|
Takashi Iwai |
18259a |
NULL so that this pointer liveness is tracked properly.
|
|
Takashi Iwai |
18259a |
|
|
Takashi Iwai |
18259a |
Fixes: 9d5cbf5fe46e ("drm/msm: add shutdown support for display platform_driver")
|
|
Takashi Iwai |
18259a |
Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
|
|
Takashi Iwai |
18259a |
Cc: Fabio Estevam <festevam@gmail.com>
|
|
Takashi Iwai |
18259a |
Cc: Krishna Manikandan <mkrishn@codeaurora.org>
|
|
Takashi Iwai |
18259a |
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
|
|
Takashi Iwai |
18259a |
Message-id: <20210325212822.3663144-1-swboyd@chromium.org>
|
|
Takashi Iwai |
18259a |
Signed-off-by: Rob Clark <robdclark@chromium.org>
|
|
Takashi Iwai |
18259a |
Acked-by: Takashi Iwai <tiwai@suse.de>
|
|
Takashi Iwai |
18259a |
|
|
Takashi Iwai |
18259a |
---
|
|
Takashi Iwai |
18259a |
drivers/gpu/drm/msm/msm_drv.c | 1 +
|
|
Takashi Iwai |
18259a |
1 file changed, 1 insertion(+)
|
|
Takashi Iwai |
18259a |
|
|
Takashi Iwai |
18259a |
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
|
|
Takashi Iwai |
18259a |
index a5c6b8c23336..196907689c82 100644
|
|
Takashi Iwai |
18259a |
--- a/drivers/gpu/drm/msm/msm_drv.c
|
|
Takashi Iwai |
18259a |
+++ b/drivers/gpu/drm/msm/msm_drv.c
|
|
Takashi Iwai |
18259a |
@@ -570,6 +570,7 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv)
|
|
Takashi Iwai |
18259a |
kfree(priv);
|
|
Takashi Iwai |
18259a |
err_put_drm_dev:
|
|
Takashi Iwai |
18259a |
drm_dev_put(ddev);
|
|
Takashi Iwai |
18259a |
+ platform_set_drvdata(pdev, NULL);
|
|
Takashi Iwai |
18259a |
return ret;
|
|
Takashi Iwai |
18259a |
}
|
|
Takashi Iwai |
18259a |
|
|
Takashi Iwai |
18259a |
--
|
|
Takashi Iwai |
18259a |
2.26.2
|
|
Takashi Iwai |
18259a |
|