From: Jonathan Liu <net147@gmail.com> To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>, Marek Vasut <marex@denx.de> Cc: dri-devel <dri-devel@lists.freedesktop.org>, linux-kernel <linux-kernel@vger.kernel.org>, Andrzej Hajda <a.hajda@samsung.com>, Neil Armstrong <narmstrong@baylibre.com>, Robert Foss <robert.foss@linaro.org>, Jonas Karlman <jonas@kwiboo.se>, Jernej Skrabec <jernej.skrabec@gmail.com>, David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>, Linus Walleij <linus.walleij@linaro.org>, Frieder Schrempf <frieder.schrempf@kontron.de> Subject: Re: [PATCH] drm/bridge: ti-sn65dsi83: Fix null pointer dereference in remove callback Date: Fri, 18 Jun 2021 13:06:07 +1000 [thread overview] Message-ID: <CANwerB0J9xKj3kjYPjzfeDvKV8JXPcDtoZaLMzkudCBz8=ZnVw@mail.gmail.com> (raw) In-Reply-To: <YMtYoaSIIRhb85fh@pendragon.ideasonboard.com> Hi Marek, On Fri, 18 Jun 2021 at 00:14, Laurent Pinchart <laurent.pinchart@ideasonboard.com> wrote: > > Hi Jonathan, > > Thank you for the patch. > > On Thu, Jun 17, 2021 at 09:19:25PM +1000, Jonathan Liu wrote: > > If attach has not been called, unloading the driver can result in a null > > pointer dereference in mipi_dsi_detach as ctx->dsi has not been assigned > > yet. > > Shouldn't this be done in a brige .detach() operation instead ? > Could you please take a look? I don't have a working setup to test moving the code to detach. > > Fixes: ceb515ba29ba6b ("drm/bridge: ti-sn65dsi83: Add TI SN65DSI83 and SN65DSI84 driver") > > Signed-off-by: Jonathan Liu <net147@gmail.com> > > --- > > drivers/gpu/drm/bridge/ti-sn65dsi83.c | 7 +++++-- > > 1 file changed, 5 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi83.c b/drivers/gpu/drm/bridge/ti-sn65dsi83.c > > index 750f2172ef08..8e9f45c5c7c1 100644 > > --- a/drivers/gpu/drm/bridge/ti-sn65dsi83.c > > +++ b/drivers/gpu/drm/bridge/ti-sn65dsi83.c > > @@ -671,8 +671,11 @@ static int sn65dsi83_remove(struct i2c_client *client) > > { > > struct sn65dsi83 *ctx = i2c_get_clientdata(client); > > > > - mipi_dsi_detach(ctx->dsi); > > - mipi_dsi_device_unregister(ctx->dsi); > > + if (ctx->dsi) { > > + mipi_dsi_detach(ctx->dsi); > > + mipi_dsi_device_unregister(ctx->dsi); > > + } > > + > > drm_bridge_remove(&ctx->bridge); > > of_node_put(ctx->host_node); > > Thanks. Regards, Jonathan
WARNING: multiple messages have this Message-ID (diff)
From: Jonathan Liu <net147@gmail.com> To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>, Marek Vasut <marex@denx.de> Cc: Jernej Skrabec <jernej.skrabec@gmail.com>, Jonas Karlman <jonas@kwiboo.se>, David Airlie <airlied@linux.ie>, Neil Armstrong <narmstrong@baylibre.com>, linux-kernel <linux-kernel@vger.kernel.org>, Robert Foss <robert.foss@linaro.org>, Frieder Schrempf <frieder.schrempf@kontron.de>, Andrzej Hajda <a.hajda@samsung.com>, dri-devel <dri-devel@lists.freedesktop.org> Subject: Re: [PATCH] drm/bridge: ti-sn65dsi83: Fix null pointer dereference in remove callback Date: Fri, 18 Jun 2021 13:06:07 +1000 [thread overview] Message-ID: <CANwerB0J9xKj3kjYPjzfeDvKV8JXPcDtoZaLMzkudCBz8=ZnVw@mail.gmail.com> (raw) In-Reply-To: <YMtYoaSIIRhb85fh@pendragon.ideasonboard.com> Hi Marek, On Fri, 18 Jun 2021 at 00:14, Laurent Pinchart <laurent.pinchart@ideasonboard.com> wrote: > > Hi Jonathan, > > Thank you for the patch. > > On Thu, Jun 17, 2021 at 09:19:25PM +1000, Jonathan Liu wrote: > > If attach has not been called, unloading the driver can result in a null > > pointer dereference in mipi_dsi_detach as ctx->dsi has not been assigned > > yet. > > Shouldn't this be done in a brige .detach() operation instead ? > Could you please take a look? I don't have a working setup to test moving the code to detach. > > Fixes: ceb515ba29ba6b ("drm/bridge: ti-sn65dsi83: Add TI SN65DSI83 and SN65DSI84 driver") > > Signed-off-by: Jonathan Liu <net147@gmail.com> > > --- > > drivers/gpu/drm/bridge/ti-sn65dsi83.c | 7 +++++-- > > 1 file changed, 5 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi83.c b/drivers/gpu/drm/bridge/ti-sn65dsi83.c > > index 750f2172ef08..8e9f45c5c7c1 100644 > > --- a/drivers/gpu/drm/bridge/ti-sn65dsi83.c > > +++ b/drivers/gpu/drm/bridge/ti-sn65dsi83.c > > @@ -671,8 +671,11 @@ static int sn65dsi83_remove(struct i2c_client *client) > > { > > struct sn65dsi83 *ctx = i2c_get_clientdata(client); > > > > - mipi_dsi_detach(ctx->dsi); > > - mipi_dsi_device_unregister(ctx->dsi); > > + if (ctx->dsi) { > > + mipi_dsi_detach(ctx->dsi); > > + mipi_dsi_device_unregister(ctx->dsi); > > + } > > + > > drm_bridge_remove(&ctx->bridge); > > of_node_put(ctx->host_node); > > Thanks. Regards, Jonathan
next prev parent reply other threads:[~2021-06-18 3:06 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-06-17 11:19 [PATCH] drm/bridge: ti-sn65dsi83: Fix null pointer dereference in remove callback Jonathan Liu 2021-06-17 11:19 ` Jonathan Liu 2021-06-17 12:49 ` Marek Vasut 2021-06-17 12:49 ` Marek Vasut 2021-06-17 14:13 ` Laurent Pinchart 2021-06-17 14:13 ` Laurent Pinchart 2021-06-18 3:06 ` Jonathan Liu [this message] 2021-06-18 3:06 ` Jonathan Liu 2021-06-18 5:40 ` Marek Vasut 2021-06-18 5:40 ` Marek Vasut
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='CANwerB0J9xKj3kjYPjzfeDvKV8JXPcDtoZaLMzkudCBz8=ZnVw@mail.gmail.com' \ --to=net147@gmail.com \ --cc=a.hajda@samsung.com \ --cc=airlied@linux.ie \ --cc=daniel@ffwll.ch \ --cc=dri-devel@lists.freedesktop.org \ --cc=frieder.schrempf@kontron.de \ --cc=jernej.skrabec@gmail.com \ --cc=jonas@kwiboo.se \ --cc=laurent.pinchart@ideasonboard.com \ --cc=linus.walleij@linaro.org \ --cc=linux-kernel@vger.kernel.org \ --cc=marex@denx.de \ --cc=narmstrong@baylibre.com \ --cc=robert.foss@linaro.org \ /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: linkBe 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.