From: Stefan Mavrodiev <stefan@olimex.com>
To: Maxime Ripard <mripard@kernel.org>
Cc: Stefan Mavrodiev <stefan@olimex.com>,
Chen-Yu Tsai <wens@csie.org>, David Airlie <airlied@linux.ie>,
Daniel Vetter <daniel@ffwll.ch>,
"open list:DRM DRIVERS FOR ALLWINNER A10"
<dri-devel@lists.freedesktop.org>,
"moderated list:ARM/Allwinner sunXi SoC support"
<linux-arm-kernel@lists.infradead.org>,
open list <linux-kernel@vger.kernel.org>,
linux-sunxi@googlegroups.com
Subject: Re: [PATCH 1/1] drm/sun4i: hdmi: Check for null pointer before cleanup
Date: Tue, 17 Dec 2019 08:45:07 +0200 [thread overview]
Message-ID: <cebda755-2649-79a1-fd08-79b13edef1a5@olimex.com> (raw)
In-Reply-To: <20191216161258.lmkq2ersfm746t7q@gilmour.lan>
Hi,
On 12/16/19 6:12 PM, Maxime Ripard wrote:
> Hi,
>
> On Mon, Dec 16, 2019 at 04:43:48PM +0200, Stefan Mavrodiev wrote:
>> It's possible hdmi->connector and hdmi->encoder divices to be NULL.
>> This can happen when building as kernel module and you try to remove
>> the module.
>>
>> This patch make simple null check, before calling the cleanup functions.
>>
>> Signed-off-by: Stefan Mavrodiev <stefan@olimex.com>
>> ---
>> drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 6 ++++--
>> 1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
>> index a7c4654445c7..b61e00f2ecb8 100644
>> --- a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
>> +++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
>> @@ -685,8 +685,10 @@ static void sun4i_hdmi_unbind(struct device *dev, struct device *master,
>> struct sun4i_hdmi *hdmi = dev_get_drvdata(dev);
>>
>> cec_unregister_adapter(hdmi->cec_adap);
>> - drm_connector_cleanup(&hdmi->connector);
>> - drm_encoder_cleanup(&hdmi->encoder);
>> + if (hdmi->connector.dev)
>> + drm_connector_cleanup(&hdmi->connector);
>> + if (hdmi->encoder.dev)
>> + drm_encoder_cleanup(&hdmi->encoder);
> Hmmm, this doesn't look right. Do you have more information on how you
> can reproduce it?
Just build sun4i_drm_hdmi as module (CONFIG_DRM_SUN4I_HDMI=m). Then try
to unload the module:
# rmmod sun4i_drm_hdmi
And you get this:
Unable to handle kernel NULL pointer dereference at virtual address 00000000
pgd = 6b032436
[00000000] *pgd=00000000
Internal error: Oops: 5 [#1] SMP ARM
Modules linked in: sun4i_drm_hdmi(-)
CPU: 0 PID: 1081 Comm: rmmod Not tainted 5.5.0-rc1-00030-g6ec417030d93 #33
Hardware name: Allwinner sun7i (A20) Family
PC is at drm_connector_cleanup+0x40/0x208
LR is at sun4i_hdmi_unbind+0x10/0x54 [sun4i_drm_hdmi]
...
I've tested that with sunxi/for-next branch on A20-OLinuXino board.
Best regards,
Stefan
>
> Maxime
next prev parent reply other threads:[~2019-12-17 6:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-16 14:43 Stefan Mavrodiev
2019-12-16 16:12 ` Maxime Ripard
2019-12-17 6:45 ` Stefan Mavrodiev [this message]
2019-12-17 11:46 ` Maxime Ripard
2019-12-17 11:49 ` Maxime Ripard
2019-12-17 11:54 ` Stefan Mavrodiev
2019-12-17 11:57 ` Maxime Ripard
2019-12-17 7:26 ` Uwe Kleine-König
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=cebda755-2649-79a1-fd08-79b13edef1a5@olimex.com \
--to=stefan@olimex.com \
--cc=airlied@linux.ie \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sunxi@googlegroups.com \
--cc=mripard@kernel.org \
--cc=wens@csie.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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®