LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] misc/pvpanic: fix panic on accessing sysfs entries
@ 2021-08-18 15:38 Mihai Carabas
2021-08-18 15:38 ` [PATCH] misc/pvpanic: fix set driver data Mihai Carabas
0 siblings, 1 reply; 4+ messages in thread
From: Mihai Carabas @ 2021-08-18 15:38 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).
Mihai Carabas (1):
misc/pvpanic: fix set driver data
drivers/misc/pvpanic/pvpanic-mmio.c | 2 ++
drivers/misc/pvpanic/pvpanic-pci.c | 2 ++
2 files changed, 4 insertions(+)
--
1.8.3.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] misc/pvpanic: fix set driver data
2021-08-18 15:38 [PATCH] misc/pvpanic: fix panic on accessing sysfs entries Mihai Carabas
@ 2021-08-18 15:38 ` Mihai Carabas
2021-08-18 21:59 ` kernel test robot
2021-08-19 12:30 ` Andy Shevchenko
0 siblings, 2 replies; 4+ messages in thread
From: Mihai Carabas @ 2021-08-18 15:38 UTC (permalink / raw)
To: arnd, gregkh, andriy.shevchenko, christophe.jaillet,
mihai.carabas, linux-kernel
Add again dev_set_drvdata 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-mmio.c | 2 ++
drivers/misc/pvpanic/pvpanic-pci.c | 2 ++
2 files changed, 4 insertions(+)
diff --git a/drivers/misc/pvpanic/pvpanic-mmio.c b/drivers/misc/pvpanic/pvpanic-mmio.c
index be40160..874f94e 100644
--- a/drivers/misc/pvpanic/pvpanic-mmio.c
+++ b/drivers/misc/pvpanic/pvpanic-mmio.c
@@ -104,6 +104,8 @@ static int pvpanic_mmio_probe(struct platform_device *pdev)
pi->capability &= ioread8(base);
pi->events = pi->capability;
+ dev_set_drvdata(dev, pi);
+
return devm_pvpanic_probe(dev, pi);
}
diff --git a/drivers/misc/pvpanic/pvpanic-pci.c b/drivers/misc/pvpanic/pvpanic-pci.c
index a43c401..2a26db8 100644
--- a/drivers/misc/pvpanic/pvpanic-pci.c
+++ b/drivers/misc/pvpanic/pvpanic-pci.c
@@ -96,6 +96,8 @@ static int pvpanic_pci_probe(struct pci_dev *pdev,
pi->capability &= ioread8(base);
pi->events = pi->capability;
+ dev_set_drvdata(dev, pi);
+
return devm_pvpanic_probe(&pdev->dev, pi);
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] misc/pvpanic: fix set driver data
2021-08-18 15:38 ` [PATCH] misc/pvpanic: fix set driver data Mihai Carabas
@ 2021-08-18 21:59 ` kernel test robot
2021-08-19 12:30 ` Andy Shevchenko
1 sibling, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-08-18 21:59 UTC (permalink / raw)
To: Mihai Carabas, arnd, gregkh, andriy.shevchenko,
christophe.jaillet, linux-kernel
Cc: clang-built-linux, kbuild-all
[-- Attachment #1: Type: text/plain, Size: 3198 bytes --]
Hi Mihai,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on soc/for-next linus/master v5.14-rc6 next-20210818]
[cannot apply to linux/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Mihai-Carabas/misc-pvpanic-fix-set-driver-data/20210819-003204
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git 09cbd1df7d2615c19e40facbe31fdcb5f1ebfa96
config: riscv-randconfig-r042-20210816 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project d2b574a4dea5b718e4386bf2e26af0126e5978ce)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/0day-ci/linux/commit/d0d6a877210c6d9ac4505c8864294dbd975f31b1
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Mihai-Carabas/misc-pvpanic-fix-set-driver-data/20210819-003204
git checkout d0d6a877210c6d9ac4505c8864294dbd975f31b1
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross O=build_dir ARCH=riscv SHELL=/bin/bash drivers/misc/pvpanic/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
>> drivers/misc/pvpanic/pvpanic-pci.c:99:18: error: use of undeclared identifier 'dev'; did you mean 'pdev'?
dev_set_drvdata(dev, pi);
^~~
pdev
drivers/misc/pvpanic/pvpanic-pci.c:73:46: note: 'pdev' declared here
static int pvpanic_pci_probe(struct pci_dev *pdev,
^
1 error generated.
vim +99 drivers/misc/pvpanic/pvpanic-pci.c
72
73 static int pvpanic_pci_probe(struct pci_dev *pdev,
74 const struct pci_device_id *ent)
75 {
76 struct pvpanic_instance *pi;
77 void __iomem *base;
78 int ret;
79
80 ret = pcim_enable_device(pdev);
81 if (ret < 0)
82 return ret;
83
84 base = pcim_iomap(pdev, 0, 0);
85 if (!base)
86 return -ENOMEM;
87
88 pi = devm_kmalloc(&pdev->dev, sizeof(*pi), GFP_KERNEL);
89 if (!pi)
90 return -ENOMEM;
91
92 pi->base = base;
93 pi->capability = PVPANIC_PANICKED | PVPANIC_CRASH_LOADED;
94
95 /* initlize capability by RDPT */
96 pi->capability &= ioread8(base);
97 pi->events = pi->capability;
98
> 99 dev_set_drvdata(dev, pi);
100
101 return devm_pvpanic_probe(&pdev->dev, pi);
102 }
103
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 34760 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] misc/pvpanic: fix set driver data
2021-08-18 15:38 ` [PATCH] misc/pvpanic: fix set driver data Mihai Carabas
2021-08-18 21:59 ` kernel test robot
@ 2021-08-19 12:30 ` Andy Shevchenko
1 sibling, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2021-08-19 12:30 UTC (permalink / raw)
To: Mihai Carabas; +Cc: arnd, gregkh, christophe.jaillet, linux-kernel
On Wed, Aug 18, 2021 at 06:38:30PM +0300, Mihai Carabas wrote:
Thank you for the report and fix! My comments below.
> Add again dev_set_drvdata in order for dev_get_drvdata to not return NULL.
dev_set_drvdata()
dev_get_drvdata()
> Fixes: 394febc9d0a6 ("misc/pvpanic: Make 'pvpanic_probe()' resource managed")
>
Shouldn't be blank line(s) in the tag block.
> Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com>
...
> + dev_set_drvdata(dev, pi);
> +
> return devm_pvpanic_probe(dev, pi);
I think it makes sense to have the above line as a part of pvpanic_probe().
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-08-19 12:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-18 15:38 [PATCH] misc/pvpanic: fix panic on accessing sysfs entries Mihai Carabas
2021-08-18 15:38 ` [PATCH] misc/pvpanic: fix set driver data Mihai Carabas
2021-08-18 21:59 ` kernel test robot
2021-08-19 12:30 ` 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).