linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] misc/pvpanic: fix set driver data
@ 2021-08-19 13:41 Mihai Carabas
  2021-08-19 13:41 ` Mihai Carabas
  0 siblings, 1 reply; 3+ messages in thread
From: Mihai Carabas @ 2021-08-19 13:41 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()

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] 3+ messages in thread

* [PATCH v2] misc/pvpanic: fix set driver data
  2021-08-19 13:41 [PATCH v2] misc/pvpanic: fix set driver data Mihai Carabas
@ 2021-08-19 13:41 ` Mihai Carabas
  2021-08-19 15:47   ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Mihai Carabas @ 2021-08-19 13:41 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>
---
 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..6ce48ce 100644
--- a/drivers/misc/pvpanic/pvpanic.c
+++ b/drivers/misc/pvpanic/pvpanic.c
@@ -81,6 +81,8 @@ int devm_pvpanic_probe(struct device *dev, struct pvpanic_instance *pi)
 	if (!pi || !pi->base)
 		return -EINVAL;
 
+	dev_set_drvdata(dev, pi);
+
 	spin_lock(&pvpanic_lock);
 	list_add(&pi->list, &pvpanic_list);
 	spin_unlock(&pvpanic_lock);
-- 
1.8.3.1


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

* Re: [PATCH v2] misc/pvpanic: fix set driver data
  2021-08-19 13:41 ` Mihai Carabas
@ 2021-08-19 15:47   ` Andy Shevchenko
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2021-08-19 15:47 UTC (permalink / raw)
  To: Mihai Carabas; +Cc: arnd, gregkh, christophe.jaillet, linux-kernel

On Thu, Aug 19, 2021 at 04:41:21PM +0300, Mihai Carabas wrote:
> Add again dev_set_drvdata(), but this time in devm_pvpanic_probe(), in order
> for dev_get_drvdata() to not return NULL.

Thanks, almost good, after addressing below feel free to add
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Fixes: 394febc9d0a6 ("misc/pvpanic: Make 'pvpanic_probe()' resource managed")
> Signed-off-by: Mihai Carabas <mihai.carabas@oracle.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..6ce48ce 100644
> --- a/drivers/misc/pvpanic/pvpanic.c
> +++ b/drivers/misc/pvpanic/pvpanic.c
> @@ -81,6 +81,8 @@ int devm_pvpanic_probe(struct device *dev, struct pvpanic_instance *pi)
>  	if (!pi || !pi->base)
>  		return -EINVAL;

> +	dev_set_drvdata(dev, pi);

I believe this should be last (or close enough) operation in the function for
the sake of logical flow.

>  	spin_lock(&pvpanic_lock);
>  	list_add(&pi->list, &pvpanic_list);
>  	spin_unlock(&pvpanic_lock);

-- 
With Best Regards,
Andy Shevchenko



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

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

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

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