public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* ufs: setting "hba" private pointer too late -- oops in ufshcd_devfreq_get_dev_status()
@ 2021-11-10 14:32 Alexey Dobriyan
  2021-11-10 18:18 ` Bart Van Assche
  0 siblings, 1 reply; 4+ messages in thread
From: Alexey Dobriyan @ 2021-11-10 14:32 UTC (permalink / raw)
  To: alim.akhtar, avri.altman; +Cc: linux-scsi

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.

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

end of thread, other threads:[~2021-11-17  0:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2021-11-17  0:59     ` Bart Van Assche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox