diff mbox series

[1/2] drm/meson: Fix invalid pointer in meson_drv_unbind()

Message ID 20190322152657.13752-1-jean-philippe.brucker@arm.com (mailing list archive)
State Not Applicable
Delegated to: Neil Armstrong
Headers show
Series [1/2] drm/meson: Fix invalid pointer in meson_drv_unbind() | expand

Commit Message

Jean-Philippe Brucker March 22, 2019, 3:26 p.m. UTC
meson_drv_bind() registers a meson_drm struct as the device's privdata,
but meson_drv_unbind() tries to retrieve a drm_device. This may cause a
segfault on shutdown:

[ 5194.593429] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000197
 ...
[ 5194.788850] Call trace:
[ 5194.791349]  drm_dev_unregister+0x1c/0x118 [drm]
[ 5194.795848]  meson_drv_unbind+0x50/0x78 [meson_drm]

Retrieve the right pointer in meson_drv_unbind().

Fixes: bbbe775ec5b5 ("drm: Add support for Amlogic Meson Graphic Controller")
Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
---
 drivers/gpu/drm/meson/meson_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Neil Armstrong March 23, 2019, 9:53 a.m. UTC | #1
Hi Jean-Philippe,

Le 22/03/2019 16:26, Jean-Philippe Brucker a écrit :
> meson_drv_bind() registers a meson_drm struct as the device's privdata,
> but meson_drv_unbind() tries to retrieve a drm_device. This may cause a
> segfault on shutdown:
> 
> [ 5194.593429] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000197
>  ...
> [ 5194.788850] Call trace:
> [ 5194.791349]  drm_dev_unregister+0x1c/0x118 [drm]
> [ 5194.795848]  meson_drv_unbind+0x50/0x78 [meson_drm]
> 
> Retrieve the right pointer in meson_drv_unbind().
> 
> Fixes: bbbe775ec5b5 ("drm: Add support for Amlogic Meson Graphic Controller")
> Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>

Thanks for working on this,
Acked-by: Neil Armstrong <narmstrong@baylibre.com>

I'll push it on drm-misc-fixes

> ---
>  drivers/gpu/drm/meson/meson_drv.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/meson/meson_drv.c b/drivers/gpu/drm/meson/meson_drv.c
> index 2281ed3eb774..7e85802c5398 100644
> --- a/drivers/gpu/drm/meson/meson_drv.c
> +++ b/drivers/gpu/drm/meson/meson_drv.c
> @@ -356,8 +356,8 @@ static int meson_drv_bind(struct device *dev)
>  
>  static void meson_drv_unbind(struct device *dev)
>  {
> -	struct drm_device *drm = dev_get_drvdata(dev);
> -	struct meson_drm *priv = drm->dev_private;
> +	struct meson_drm *priv = dev_get_drvdata(dev);
> +	struct drm_device *drm = priv->drm;
>  
>  	if (priv->canvas) {
>  		meson_canvas_free(priv->canvas, priv->canvas_id_osd1);
>
Neil Armstrong March 25, 2019, 10:19 a.m. UTC | #2
On 22/03/2019 16:26, Jean-Philippe Brucker wrote:
> meson_drv_bind() registers a meson_drm struct as the device's privdata,
> but meson_drv_unbind() tries to retrieve a drm_device. This may cause a
> segfault on shutdown:
> 
> [ 5194.593429] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000197
>  ...
> [ 5194.788850] Call trace:
> [ 5194.791349]  drm_dev_unregister+0x1c/0x118 [drm]
> [ 5194.795848]  meson_drv_unbind+0x50/0x78 [meson_drm]
> 
> Retrieve the right pointer in meson_drv_unbind().
> 
> Fixes: bbbe775ec5b5 ("drm: Add support for Amlogic Meson Graphic Controller")
> Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
> ---
>  drivers/gpu/drm/meson/meson_drv.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/meson/meson_drv.c b/drivers/gpu/drm/meson/meson_drv.c
> index 2281ed3eb774..7e85802c5398 100644
> --- a/drivers/gpu/drm/meson/meson_drv.c
> +++ b/drivers/gpu/drm/meson/meson_drv.c
> @@ -356,8 +356,8 @@ static int meson_drv_bind(struct device *dev)
>  
>  static void meson_drv_unbind(struct device *dev)
>  {
> -	struct drm_device *drm = dev_get_drvdata(dev);
> -	struct meson_drm *priv = drm->dev_private;
> +	struct meson_drm *priv = dev_get_drvdata(dev);
> +	struct drm_device *drm = priv->drm;
>  
>  	if (priv->canvas) {
>  		meson_canvas_free(priv->canvas, priv->canvas_id_osd1);
> 

Applied both to drm-misc-fixes, thanks !

Neil
diff mbox series

Patch

diff --git a/drivers/gpu/drm/meson/meson_drv.c b/drivers/gpu/drm/meson/meson_drv.c
index 2281ed3eb774..7e85802c5398 100644
--- a/drivers/gpu/drm/meson/meson_drv.c
+++ b/drivers/gpu/drm/meson/meson_drv.c
@@ -356,8 +356,8 @@  static int meson_drv_bind(struct device *dev)
 
 static void meson_drv_unbind(struct device *dev)
 {
-	struct drm_device *drm = dev_get_drvdata(dev);
-	struct meson_drm *priv = drm->dev_private;
+	struct meson_drm *priv = dev_get_drvdata(dev);
+	struct drm_device *drm = priv->drm;
 
 	if (priv->canvas) {
 		meson_canvas_free(priv->canvas, priv->canvas_id_osd1);