linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] misc/pvpanic: fix set driver data
@ 2021-08-19 15:12 Mihai Carabas
  2021-08-19 15:12 ` Mihai Carabas
  0 siblings, 1 reply; 2+ messages in thread
From: Mihai Carabas @ 2021-08-19 15:12 UTC (permalink / raw)
  To: arnd, gregkh, andriy.shevchenko, christophe.jaillet,
	mihai.carabas, linux-kernel

Commit 394febc9d0a6 ("misc/pvpanic: Make 'pvpanic_probe()' resource managed")
removed dev_set_drvdata() from the probe function and accessing sysfs entries
from userspace is causing a panic in the kernel (pi = dev_get_drvdata(dev) ->
pi is NULL).

v2:
- fixes a compile issue with CONFIG_PVPANIC_PCI
- move dev_set_drvdata() to devm_pvpanic_probe()

v3:
- move dev_set_drvdata() at the end of devm_pvpanic_probe()

Mihai Carabas (1):
  misc/pvpanic: fix set driver data

 drivers/misc/pvpanic/pvpanic.c | 2 ++
 1 file changed, 2 insertions(+)

-- 
1.8.3.1


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

* [PATCH v3] misc/pvpanic: fix set driver data
  2021-08-19 15:12 [PATCH v3] misc/pvpanic: fix set driver data Mihai Carabas
@ 2021-08-19 15:12 ` Mihai Carabas
  0 siblings, 0 replies; 2+ messages in thread
From: Mihai Carabas @ 2021-08-19 15:12 UTC (permalink / raw)
  To: arnd, gregkh, andriy.shevchenko, christophe.jaillet,
	mihai.carabas, linux-kernel

Add again dev_set_drvdata(), but this time in devm_pvpanic_probe(), in order
for dev_get_drvdata() to not return NULL.

Fixes: 394febc9d0a6 ("misc/pvpanic: Make 'pvpanic_probe()' resource managed")
Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/misc/pvpanic/pvpanic.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/misc/pvpanic/pvpanic.c b/drivers/misc/pvpanic/pvpanic.c
index 02b807c..bb7aa63 100644
--- a/drivers/misc/pvpanic/pvpanic.c
+++ b/drivers/misc/pvpanic/pvpanic.c
@@ -85,6 +85,8 @@ int devm_pvpanic_probe(struct device *dev, struct pvpanic_instance *pi)
 	list_add(&pi->list, &pvpanic_list);
 	spin_unlock(&pvpanic_lock);
 
+	dev_set_drvdata(dev, pi);
+
 	return devm_add_action_or_reset(dev, pvpanic_remove, pi);
 }
 EXPORT_SYMBOL_GPL(devm_pvpanic_probe);
-- 
1.8.3.1


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

end of thread, other threads:[~2021-08-19 16:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-19 15:12 [PATCH v3] misc/pvpanic: fix set driver data Mihai Carabas
2021-08-19 15:12 ` Mihai Carabas

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).