linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/mcde: dsi: Fix invalid pointer dereference if panel cannot be found
@ 2019-11-18 13:02 Stephan Gerhold
  2019-11-20 20:32 ` Linus Walleij
  0 siblings, 1 reply; 2+ messages in thread
From: Stephan Gerhold @ 2019-11-18 13:02 UTC (permalink / raw)
  To: Linus Walleij
  Cc: David Airlie, Daniel Vetter, dri-devel, linux-kernel, Stephan Gerhold

The "panel" pointer is not reset to NULL if of_drm_find_panel()
returns an error. Therefore we later assume that a panel was found,
and try to dereference the error pointer, resulting in:

    mcde-dsi a0351000.dsi: failed to find panel try bridge (4294966779)
    Unable to handle kernel paging request at virtual address fffffe03
    PC is at drm_panel_bridge_add.part.0+0x10/0x5c
    LR is at mcde_dsi_bind+0x120/0x464
    ...

Reset "panel" to NULL to avoid this problem.
Also change the format string of the error to %ld to print
the negative errors correctly. The crash above then becomes:

    mcde-dsi a0351000.dsi: failed to find panel try bridge (-517)
    mcde-dsi a0351000.dsi: no panel or bridge
    ...

Fixes: 5fc537bfd000 ("drm/mcde: Add new driver for ST-Ericsson MCDE")
Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
---
 drivers/gpu/drm/mcde/mcde_dsi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/mcde/mcde_dsi.c b/drivers/gpu/drm/mcde/mcde_dsi.c
index 03896a1f339a..eb3a855aef9a 100644
--- a/drivers/gpu/drm/mcde/mcde_dsi.c
+++ b/drivers/gpu/drm/mcde/mcde_dsi.c
@@ -924,11 +924,13 @@ static int mcde_dsi_bind(struct device *dev, struct device *master,
 	for_each_available_child_of_node(dev->of_node, child) {
 		panel = of_drm_find_panel(child);
 		if (IS_ERR(panel)) {
-			dev_err(dev, "failed to find panel try bridge (%lu)\n",
+			dev_err(dev, "failed to find panel try bridge (%ld)\n",
 				PTR_ERR(panel));
+			panel = NULL;
+
 			bridge = of_drm_find_bridge(child);
 			if (IS_ERR(bridge)) {
-				dev_err(dev, "failed to find bridge (%lu)\n",
+				dev_err(dev, "failed to find bridge (%ld)\n",
 					PTR_ERR(bridge));
 				return PTR_ERR(bridge);
 			}
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/mcde: dsi: Fix invalid pointer dereference if panel cannot be found
  2019-11-18 13:02 [PATCH] drm/mcde: dsi: Fix invalid pointer dereference if panel cannot be found Stephan Gerhold
@ 2019-11-20 20:32 ` Linus Walleij
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2019-11-20 20:32 UTC (permalink / raw)
  To: Stephan Gerhold
  Cc: David Airlie, Daniel Vetter, open list:DRM PANEL DRIVERS, linux-kernel

On Mon, Nov 18, 2019 at 2:04 PM Stephan Gerhold <stephan@gerhold.net> wrote:

> The "panel" pointer is not reset to NULL if of_drm_find_panel()
> returns an error. Therefore we later assume that a panel was found,
> and try to dereference the error pointer, resulting in:
>
>     mcde-dsi a0351000.dsi: failed to find panel try bridge (4294966779)
>     Unable to handle kernel paging request at virtual address fffffe03
>     PC is at drm_panel_bridge_add.part.0+0x10/0x5c
>     LR is at mcde_dsi_bind+0x120/0x464
>     ...
>
> Reset "panel" to NULL to avoid this problem.
> Also change the format string of the error to %ld to print
> the negative errors correctly. The crash above then becomes:
>
>     mcde-dsi a0351000.dsi: failed to find panel try bridge (-517)
>     mcde-dsi a0351000.dsi: no panel or bridge
>     ...
>
> Fixes: 5fc537bfd000 ("drm/mcde: Add new driver for ST-Ericsson MCDE")
> Signed-off-by: Stephan Gerhold <stephan@gerhold.net>

Patch applied and pushed to drm-misc-fixes, thanks!

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-11-20 20:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-18 13:02 [PATCH] drm/mcde: dsi: Fix invalid pointer dereference if panel cannot be found Stephan Gerhold
2019-11-20 20:32 ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).