All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/1] PCI / PM: check all fields in pci_set_platform_pm()
@ 2016-06-06 14:25 Andy Shevchenko
  2016-06-08  0:17 ` Rafael J. Wysocki
  2016-07-19 21:37 ` Bjorn Helgaas
  0 siblings, 2 replies; 5+ messages in thread
From: Andy Shevchenko @ 2016-06-06 14:25 UTC (permalink / raw)
  To: linux-pci, Bjorn Helgaas, Rafael J. Wysocki, linux-pm; +Cc: Andy Shevchenko

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>
---
 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->choose_state
-	    || !ops->sleep_wake)
+	if (!ops->is_manageable || !ops->set_state || !ops->choose_state ||
+	    !ops->sleep_wake || !ops->run_wake || !ops->need_resume)
 		return -EINVAL;
 	pci_platform_pm = ops;
 	return 0;
-- 
2.8.1


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

* Re: [PATCH v1 1/1] PCI / PM: check all fields in pci_set_platform_pm()
  2016-06-06 14:25 [PATCH v1 1/1] PCI / PM: check all fields in pci_set_platform_pm() Andy Shevchenko
@ 2016-06-08  0:17 ` Rafael J. Wysocki
  2016-06-08  9:04   ` Andy Shevchenko
  2016-07-19 21:37 ` Bjorn Helgaas
  1 sibling, 1 reply; 5+ messages in thread
From: Rafael J. Wysocki @ 2016-06-08  0:17 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-pci, Bjorn Helgaas, linux-pm

On Monday, June 06, 2016 05:25:33 PM Andy Shevchenko wrote:
> 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?

> ---
>  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->choose_state
> -	    || !ops->sleep_wake)
> +	if (!ops->is_manageable || !ops->set_state || !ops->choose_state ||
> +	    !ops->sleep_wake || !ops->run_wake || !ops->need_resume)
>  		return -EINVAL;
>  	pci_platform_pm = ops;
>  	return 0;
> 


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

* Re: [PATCH v1 1/1] PCI / PM: check all fields in pci_set_platform_pm()
  2016-06-08  0:17 ` Rafael J. Wysocki
@ 2016-06-08  9:04   ` Andy Shevchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2016-06-08  9:04 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: linux-pci, Bjorn Helgaas, linux-pm

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


> > ---
> >  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-
> > >choose_state
> > -	    || !ops->sleep_wake)
> > +	if (!ops->is_manageable || !ops->set_state || !ops-
> > >choose_state ||
> > +	    !ops->sleep_wake || !ops->run_wake || !ops-
> > >need_resume)
> >  		return -EINVAL;
> >  	pci_platform_pm = ops;
> >  	return 0;
> > 
> 

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

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

* Re: [PATCH v1 1/1] PCI / PM: check all fields in pci_set_platform_pm()
  2016-06-06 14:25 [PATCH v1 1/1] PCI / PM: check all fields in pci_set_platform_pm() Andy Shevchenko
  2016-06-08  0:17 ` Rafael J. Wysocki
@ 2016-07-19 21:37 ` Bjorn Helgaas
  2016-07-19 22:04   ` Rafael J. Wysocki
  1 sibling, 1 reply; 5+ messages in thread
From: Bjorn Helgaas @ 2016-07-19 21:37 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-pci, Bjorn Helgaas, Rafael J. Wysocki, linux-pm

On Mon, Jun 06, 2016 at 05:25:33PM +0300, Andy Shevchenko wrote:
> 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>
> ---
>  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->choose_state
> -	    || !ops->sleep_wake)
> +	if (!ops->is_manageable || !ops->set_state || !ops->choose_state ||
> +	    !ops->sleep_wake || !ops->run_wake || !ops->need_resume)
>  		return -EINVAL;

This looks OK to me.  platform_pci_run_wake() and
platform_pci_need_resume() assume that if pci_platform_pm is set,
pci_platform_pm->run_wake and pci_platform_pm->need_resume are valid
function pointers.  This is analogous to what we already do for
ops->is_manageable, etc.

Rafael, do you want to take this or should I?

>  	pci_platform_pm = ops;
>  	return 0;
> -- 
> 2.8.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v1 1/1] PCI / PM: check all fields in pci_set_platform_pm()
  2016-07-19 21:37 ` Bjorn Helgaas
@ 2016-07-19 22:04   ` Rafael J. Wysocki
  0 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2016-07-19 22:04 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Andy Shevchenko, Linux PCI, Bjorn Helgaas, Rafael J. Wysocki, Linux PM

On Tue, Jul 19, 2016 at 11:37 PM, Bjorn Helgaas <helgaas@kernel.org> wrote:
> On Mon, Jun 06, 2016 at 05:25:33PM +0300, Andy Shevchenko wrote:
>> 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>
>> ---
>>  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->choose_state
>> -         || !ops->sleep_wake)
>> +     if (!ops->is_manageable || !ops->set_state || !ops->choose_state ||
>> +         !ops->sleep_wake || !ops->run_wake || !ops->need_resume)
>>               return -EINVAL;
>
> This looks OK to me.  platform_pci_run_wake() and
> platform_pci_need_resume() assume that if pci_platform_pm is set,
> pci_platform_pm->run_wake and pci_platform_pm->need_resume are valid
> function pointers.  This is analogous to what we already do for
> ops->is_manageable, etc.
>
> Rafael, do you want to take this or should I?
>
>>       pci_platform_pm = ops;
>>       return 0;
>> --

I can take it.

Thanks,
Rafael

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

end of thread, other threads:[~2016-07-19 22:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-06 14:25 [PATCH v1 1/1] PCI / PM: check all fields in pci_set_platform_pm() Andy Shevchenko
2016-06-08  0:17 ` Rafael J. Wysocki
2016-06-08  9:04   ` Andy Shevchenko
2016-07-19 21:37 ` Bjorn Helgaas
2016-07-19 22:04   ` Rafael J. Wysocki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.