Thread (5 messages) 5 messages, 4 authors, 2016-07-19

Re: [PATCH v1 1/1] PCI / PM: check all fields in pci_set_platform_pm()

From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: 2016-06-08 09:04:06
Also in: linux-pci

On Wed, 2016-06-08 at 02:17 +0200, Rafael J. Wysocki wrote:
On Monday, June 06, 2016 05:25:33 PM Andy Shevchenko wrote:
quoted
When assign new PCI platform PM operations check for all mandatory
fields to
prevent NULL pointer dereference.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
OK in principle, but what's the motivation?
I didn't investigate the guts of the core code, but I'm about to add new
module which will use these facilities. Since the module is slightly
based on existing code for older kernels I noticed those new callbacks.
To prevent potential NULL pointer dereference.

quoted
---
 drivers/pci/pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index c8b4dbd..badbddc 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -530,8 +530,8 @@ static const struct pci_platform_pm_ops
*pci_platform_pm;
 
 int pci_set_platform_pm(const struct pci_platform_pm_ops *ops)
 {
-	if (!ops->is_manageable || !ops->set_state || !ops-
quoted
choose_state
-	    || !ops->sleep_wake)
+	if (!ops->is_manageable || !ops->set_state || !ops-
quoted
choose_state ||
+	    !ops->sleep_wake || !ops->run_wake || !ops-
quoted
need_resume)
 		return -EINVAL;
 	pci_platform_pm = ops;
 	return 0;
-- 
Andy Shevchenko [off-list ref]
Intel Finland Oy
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help