All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sam Ravnborg <sam@ravnborg.org>
To: Anitha Chrisanthus <anitha.chrisanthus@intel.com>
Cc: edmund.j.dea@intel.com, Dan Carpenter <dan.carpenter@oracle.com>,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 12/14] drm/kmb: Fix possible oops in error handling
Date: Wed, 28 Jul 2021 09:27:07 +0200	[thread overview]
Message-ID: <YQEGy7LvaR3x1nHz@ravnborg.org> (raw)
In-Reply-To: <20210728003126.1425028-12-anitha.chrisanthus@intel.com>

Hi Anitha,

On Tue, Jul 27, 2021 at 05:31:24PM -0700, Anitha Chrisanthus wrote:
> If kmb_dsi_init() fails the "kmb->kmb_dsi" variable is an error pointer.
> This can potentially result in kernel panic when kmb_dsi_host_unregister is
> called.
> 
> Fixes: 7f7b96a8a0a1 ("drm/kmb: Add support for KeemBay Display")
> Fixes: 98521f4d4b4c ("drm/kmb: Mipi DSI part of the display driver")
> Cc: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Anitha Chrisanthus <anitha.chrisanthus@intel.com>
> ---
>  drivers/gpu/drm/kmb/kmb_drv.c | 9 ++++++---
>  drivers/gpu/drm/kmb/kmb_dsi.c | 9 +++++----
>  drivers/gpu/drm/kmb/kmb_dsi.h | 3 ++-
>  3 files changed, 13 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/kmb/kmb_drv.c b/drivers/gpu/drm/kmb/kmb_drv.c
> index bb7eca9e13ae..12f35c43d838 100644
> --- a/drivers/gpu/drm/kmb/kmb_drv.c
> +++ b/drivers/gpu/drm/kmb/kmb_drv.c
> @@ -454,8 +454,9 @@ static int kmb_remove(struct platform_device *pdev)
>  	dev_set_drvdata(dev, NULL);
>  
>  	/* Unregister DSI host */
> -	kmb_dsi_host_unregister(kmb->kmb_dsi);
> +	kmb_dsi_host_unregister();
>  	drm_atomic_helper_shutdown(drm);
> +	drm_dev_put(drm);
>  	return 0;
>  }
>  
> @@ -519,7 +520,7 @@ static int kmb_probe(struct platform_device *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;
> +		goto err_free2;
>  	}
>  
>  	kmb->kmb_dsi->dev = &dsi_pdev->dev;
> @@ -555,8 +556,10 @@ static int kmb_probe(struct platform_device *pdev)
>  	drm_crtc_cleanup(&kmb->crtc);
>  	drm_mode_config_cleanup(&kmb->drm);
>   err_free1:
> +	kmb_dsi_clk_disable(kmb->kmb_dsi);
> + err_free2:
>  	dev_set_drvdata(dev, NULL);
> -	kmb_dsi_host_unregister(kmb->kmb_dsi);
> +	kmb_dsi_host_unregister();
>  

This really looks like a step backward. There should not be a eed to
call unregister if kmb_dsi is not a valid pointer in the first place.
Also drn_dev_put() should not be needed with the use of drmm
infrastructure.



>  	return ret;
>  }
> diff --git a/drivers/gpu/drm/kmb/kmb_dsi.c b/drivers/gpu/drm/kmb/kmb_dsi.c
> index 1cca0fe6f35f..a500172ada87 100644
> --- a/drivers/gpu/drm/kmb/kmb_dsi.c
> +++ b/drivers/gpu/drm/kmb/kmb_dsi.c
> @@ -172,17 +172,17 @@ mipi_hs_freq_range[MIPI_DPHY_DEFAULT_BIT_RATES] = {
>  	{.default_bit_rate_mbps = 2500, .hsfreqrange_code = 0x49}
>  };
>  
> -static void kmb_dsi_clk_disable(struct kmb_dsi *kmb_dsi)
> +void kmb_dsi_clk_disable(struct kmb_dsi *kmb_dsi)
>  {
>  	clk_disable_unprepare(kmb_dsi->clk_mipi);
>  	clk_disable_unprepare(kmb_dsi->clk_mipi_ecfg);
>  	clk_disable_unprepare(kmb_dsi->clk_mipi_cfg);
>  }
>  
> -void kmb_dsi_host_unregister(struct kmb_dsi *kmb_dsi)
> +void kmb_dsi_host_unregister(void)
>  {
> -	kmb_dsi_clk_disable(kmb_dsi);
> -	mipi_dsi_host_unregister(kmb_dsi->host);
> +	if (dsi_host)
> +		mipi_dsi_host_unregister(dsi_host);
>  }
I thought we had killed the global dsi_host variable??
Seems some cleanup is till needed here.

	Sam

  reply	other threads:[~2021-07-28  7:27 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-28  0:31 [PATCH 01/14] drm/kmb: Enable LCD DMA for low TVDDCV Anitha Chrisanthus
2021-07-28  0:31 ` [PATCH 02/14] drm/kmb: Define driver date and major/minor version Anitha Chrisanthus
2021-07-28  7:06   ` Sam Ravnborg
2021-08-04 18:13   ` Thomas Zimmermann
2021-08-05 23:53     ` Chrisanthus, Anitha
2021-07-28  0:31 ` [PATCH 03/14] drm/kmb: Work around for higher system clock Anitha Chrisanthus
2021-07-28  0:31 ` [PATCH 04/14] drm/kmb : W/A for 256B cache alignment for video Anitha Chrisanthus
2021-07-28  7:16   ` Sam Ravnborg
2021-07-28 22:54     ` Chrisanthus, Anitha
2021-07-28  0:31 ` [PATCH 05/14] drm/kmb: Limit supported mode to 1080p Anitha Chrisanthus
2021-07-28  0:31 ` [PATCH 06/14] drm/kmb: Remove clearing DPHY regs Anitha Chrisanthus
2021-07-28  0:31 ` [PATCH 07/14] drm/kmb: Disable change of plane parameters Anitha Chrisanthus
2021-07-28  0:31 ` [PATCH 08/14] drm/kmb: Corrected typo in handle_lcd_irq Anitha Chrisanthus
2021-07-28  0:31 ` [PATCH 09/14] drm/kmb : W/A for planar formats Anitha Chrisanthus
2021-07-28 22:48   ` Chrisanthus, Anitha
2021-07-28  0:31 ` [PATCH 10/14] drm/kmb: Enable ADV bridge after modeset Anitha Chrisanthus
2021-07-28  7:22   ` Sam Ravnborg
2021-07-28  0:31 ` [PATCH 11/14] drm/kmb: Prune display modes with CRTC vfp < 4 Anitha Chrisanthus
2021-07-28  0:31 ` [PATCH 12/14] drm/kmb: Fix possible oops in error handling Anitha Chrisanthus
2021-07-28  7:27   ` Sam Ravnborg [this message]
2021-07-28 23:23     ` Chrisanthus, Anitha
2021-07-28  7:46   ` Dan Carpenter
2021-07-28  0:31 ` [PATCH 13/14] drm/kmb: Enable alpha blended second plane Anitha Chrisanthus
2021-07-28  7:29   ` Sam Ravnborg
2021-08-02 20:44     ` Chrisanthus, Anitha
2021-08-03  5:10       ` Sam Ravnborg
2021-09-08 17:50         ` Thomas Zimmermann
2021-09-08 19:31           ` Sam Ravnborg
2021-09-09 17:46             ` Thomas Zimmermann
2021-07-28  0:31 ` [PATCH 14/14] drm/kmb: Enable support for fbcon (framebuffer console) Anitha Chrisanthus
2021-07-28  4:46   ` kernel test robot
2021-07-28  7:31   ` Sam Ravnborg
2021-07-28 23:03     ` Chrisanthus, Anitha
2021-07-31  5:27   ` kernel test robot
2021-07-28  7:04 ` [PATCH 01/14] drm/kmb: Enable LCD DMA for low TVDDCV Sam Ravnborg
2021-07-29 18:48   ` Chrisanthus, Anitha
2021-07-29 19:00     ` Sam Ravnborg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YQEGy7LvaR3x1nHz@ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=anitha.chrisanthus@intel.com \
    --cc=dan.carpenter@oracle.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=edmund.j.dea@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.