From: Alexey Dobriyan <adobriyan@gmail.com>
To: Bart Van Assche <bvanassche@acm.org>
Cc: alim.akhtar@samsung.com, avri.altman@wdc.com, linux-scsi@vger.kernel.org
Subject: Re: ufs: setting "hba" private pointer too late -- oops in ufshcd_devfreq_get_dev_status()
Date: Thu, 11 Nov 2021 23:28:19 +0300 [thread overview]
Message-ID: <YY184y876Ghm+7Ly@localhost.localdomain> (raw)
In-Reply-To: <831b95a6-c097-9425-a6a8-cc599a14614c@acm.org>
On Wed, Nov 10, 2021 at 10:18:15AM -0800, Bart Van Assche wrote:
> On 11/10/21 6:32 AM, Alexey Dobriyan wrote:
> > I've stumbled into a race while working on an earlier kernel,
> > but it looks like mainline is affected as well.
> >
> > err = ufshcd_init(hba, mmio_base, irq);
> > async_schedule(ufshcd_async_scan, hba);
> > ufshcd_add_lus(hba);
> > if (ufshcd_is_clkscaling_supported(hba)) {
> > [enable devfreq]
> >
> > platform_set_drvdata(pdev, hba);
> >
> > Device's private pointer is set too late, as devfreq hook get HBA
> > pointer from private data and uses it:
> >
> > static int ufshcd_devfreq_get_dev_status(struct device *dev, struct devfreq_dev_status *stat)
> > {
> > struct ufs_hba *hba = dev_get_drvdata(dev);
> > if (!ufshcd_is_clkscaling_supported(hba))
> > return -EINVAL;
> >
> > Unable to handle kernel NULL pointer dereference at virtual address ...0f10
> > pc : ufshcd_devfreq_get_dev_status
> > lr : devfreq_simple_ondemand_func
> > update_devfreq
> > devfreq_monitor
> >
> >
> > I reproduced it by turning async LU scan into sync, so it is easier to
> > trigger.
>
> Hi Alexey,
>
> Thanks for having reported this. Do you perhaps plan to post a patch to fix
> this?
Not really, my workaround is
if (!hba) {
return -EINVAL;
}
But it is likely incorrect.
next prev parent reply other threads:[~2021-11-11 20:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-10 14:32 ufs: setting "hba" private pointer too late -- oops in ufshcd_devfreq_get_dev_status() Alexey Dobriyan
2021-11-10 18:18 ` Bart Van Assche
2021-11-11 20:28 ` Alexey Dobriyan [this message]
2021-11-17 0:59 ` Bart Van Assche
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=YY184y876Ghm+7Ly@localhost.localdomain \
--to=adobriyan@gmail.com \
--cc=alim.akhtar@samsung.com \
--cc=avri.altman@wdc.com \
--cc=bvanassche@acm.org \
--cc=linux-scsi@vger.kernel.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