* [patch] driver-core: dev_to_node() should handle NULL pointers
@ 2012-07-20 6:56 ` Dan Carpenter
0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2012-07-20 6:56 UTC (permalink / raw)
To: Grant Likely
Cc: Rob Herring, Greg Kroah-Hartman, Lars-Peter Clausen,
linux-kernel, devicetree-discuss, kernel-janitors
What prompted this patch is that in dma_pool_create() we call
dev_to_node() before checking whether "dev" is NULL. It looks like
there are places which call dma_pool_create() with a NULL pointer. An
example is in drivers/usb/gadget/amd5536udc.c.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Static checker fix.
diff --git a/include/linux/device.h b/include/linux/device.h
index aa7b3b4..c80e7a8d 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -714,7 +714,9 @@ int dev_set_name(struct device *dev, const char *name, ...);
#ifdef CONFIG_NUMA
static inline int dev_to_node(struct device *dev)
{
- return dev->numa_node;
+ if (dev)
+ return dev->numa_node;
+ return -1;
}
static inline void set_dev_node(struct device *dev, int node)
{
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [patch] driver-core: dev_to_node() should handle NULL pointers
@ 2012-07-20 6:56 ` Dan Carpenter
0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2012-07-20 6:56 UTC (permalink / raw)
To: Grant Likely
Cc: Rob Herring, Greg Kroah-Hartman, Lars-Peter Clausen,
linux-kernel, devicetree-discuss, kernel-janitors
What prompted this patch is that in dma_pool_create() we call
dev_to_node() before checking whether "dev" is NULL. It looks like
there are places which call dma_pool_create() with a NULL pointer. An
example is in drivers/usb/gadget/amd5536udc.c.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Static checker fix.
diff --git a/include/linux/device.h b/include/linux/device.h
index aa7b3b4..c80e7a8d 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -714,7 +714,9 @@ int dev_set_name(struct device *dev, const char *name, ...);
#ifdef CONFIG_NUMA
static inline int dev_to_node(struct device *dev)
{
- return dev->numa_node;
+ if (dev)
+ return dev->numa_node;
+ return -1;
}
static inline void set_dev_node(struct device *dev, int node)
{
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [patch] driver-core: dev_to_node() should handle NULL pointers
2012-07-20 6:56 ` Dan Carpenter
@ 2012-07-20 15:00 ` Greg Kroah-Hartman
-1 siblings, 0 replies; 8+ messages in thread
From: Greg Kroah-Hartman @ 2012-07-20 15:00 UTC (permalink / raw)
To: Dan Carpenter
Cc: Grant Likely, Rob Herring, Lars-Peter Clausen, linux-kernel,
devicetree-discuss, kernel-janitors
On Fri, Jul 20, 2012 at 09:56:23AM +0300, Dan Carpenter wrote:
> What prompted this patch is that in dma_pool_create() we call
> dev_to_node() before checking whether "dev" is NULL. It looks like
> there are places which call dma_pool_create() with a NULL pointer. An
> example is in drivers/usb/gadget/amd5536udc.c.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> Static checker fix.
>
> diff --git a/include/linux/device.h b/include/linux/device.h
> index aa7b3b4..c80e7a8d 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -714,7 +714,9 @@ int dev_set_name(struct device *dev, const char *name, ...);
> #ifdef CONFIG_NUMA
> static inline int dev_to_node(struct device *dev)
> {
> - return dev->numa_node;
> + if (dev)
> + return dev->numa_node;
> + return -1;
What happens if this function returns -1? Can the callers properly
handle this?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] driver-core: dev_to_node() should handle NULL pointers
@ 2012-07-20 15:00 ` Greg Kroah-Hartman
0 siblings, 0 replies; 8+ messages in thread
From: Greg Kroah-Hartman @ 2012-07-20 15:00 UTC (permalink / raw)
To: Dan Carpenter
Cc: Grant Likely, Rob Herring, Lars-Peter Clausen, linux-kernel,
devicetree-discuss, kernel-janitors
On Fri, Jul 20, 2012 at 09:56:23AM +0300, Dan Carpenter wrote:
> What prompted this patch is that in dma_pool_create() we call
> dev_to_node() before checking whether "dev" is NULL. It looks like
> there are places which call dma_pool_create() with a NULL pointer. An
> example is in drivers/usb/gadget/amd5536udc.c.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> Static checker fix.
>
> diff --git a/include/linux/device.h b/include/linux/device.h
> index aa7b3b4..c80e7a8d 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -714,7 +714,9 @@ int dev_set_name(struct device *dev, const char *name, ...);
> #ifdef CONFIG_NUMA
> static inline int dev_to_node(struct device *dev)
> {
> - return dev->numa_node;
> + if (dev)
> + return dev->numa_node;
> + return -1;
What happens if this function returns -1? Can the callers properly
handle this?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] driver-core: dev_to_node() should handle NULL pointers
2012-07-20 15:00 ` Greg Kroah-Hartman
@ 2012-07-20 15:18 ` Dan Carpenter
-1 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2012-07-20 15:18 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Grant Likely, Rob Herring, Lars-Peter Clausen, linux-kernel,
devicetree-discuss, kernel-janitors
On Fri, Jul 20, 2012 at 08:00:42AM -0700, Greg Kroah-Hartman wrote:
> On Fri, Jul 20, 2012 at 09:56:23AM +0300, Dan Carpenter wrote:
> > What prompted this patch is that in dma_pool_create() we call
> > dev_to_node() before checking whether "dev" is NULL. It looks like
> > there are places which call dma_pool_create() with a NULL pointer. An
> > example is in drivers/usb/gadget/amd5536udc.c.
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> > Static checker fix.
> >
> > diff --git a/include/linux/device.h b/include/linux/device.h
> > index aa7b3b4..c80e7a8d 100644
> > --- a/include/linux/device.h
> > +++ b/include/linux/device.h
> > @@ -714,7 +714,9 @@ int dev_set_name(struct device *dev, const char *name, ...);
> > #ifdef CONFIG_NUMA
> > static inline int dev_to_node(struct device *dev)
> > {
> > - return dev->numa_node;
> > + if (dev)
> > + return dev->numa_node;
> > + return -1;
>
> What happens if this function returns -1? Can the callers properly
> handle this?
>
Gar. Now I'm not sure any more.
-1 means no affinity and it's what the dev_to_node() returns if NUMA
is disabled. But now I think probably it's important to get the
NUMA node correct in dma_pool_create() so this isn't the right
answer.
dma_pool_create() is not correct. It has code to handle a NULL
"dev" pointer, but the dev_to_node() dereference will cause an oops
before we reach it. I'm think this is a real issue that affects a
couple drivers. Maybe those people compile without NUMA?
I'm not sure the right fix now.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] driver-core: dev_to_node() should handle NULL pointers
@ 2012-07-20 15:18 ` Dan Carpenter
0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2012-07-20 15:18 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Grant Likely, Rob Herring, Lars-Peter Clausen, linux-kernel,
devicetree-discuss, kernel-janitors
On Fri, Jul 20, 2012 at 08:00:42AM -0700, Greg Kroah-Hartman wrote:
> On Fri, Jul 20, 2012 at 09:56:23AM +0300, Dan Carpenter wrote:
> > What prompted this patch is that in dma_pool_create() we call
> > dev_to_node() before checking whether "dev" is NULL. It looks like
> > there are places which call dma_pool_create() with a NULL pointer. An
> > example is in drivers/usb/gadget/amd5536udc.c.
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> > Static checker fix.
> >
> > diff --git a/include/linux/device.h b/include/linux/device.h
> > index aa7b3b4..c80e7a8d 100644
> > --- a/include/linux/device.h
> > +++ b/include/linux/device.h
> > @@ -714,7 +714,9 @@ int dev_set_name(struct device *dev, const char *name, ...);
> > #ifdef CONFIG_NUMA
> > static inline int dev_to_node(struct device *dev)
> > {
> > - return dev->numa_node;
> > + if (dev)
> > + return dev->numa_node;
> > + return -1;
>
> What happens if this function returns -1? Can the callers properly
> handle this?
>
Gar. Now I'm not sure any more.
-1 means no affinity and it's what the dev_to_node() returns if NUMA
is disabled. But now I think probably it's important to get the
NUMA node correct in dma_pool_create() so this isn't the right
answer.
dma_pool_create() is not correct. It has code to handle a NULL
"dev" pointer, but the dev_to_node() dereference will cause an oops
before we reach it. I'm think this is a real issue that affects a
couple drivers. Maybe those people compile without NUMA?
I'm not sure the right fix now.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] driver-core: dev_to_node() should handle NULL pointers
2012-07-20 15:18 ` Dan Carpenter
@ 2012-08-16 17:23 ` Greg Kroah-Hartman
-1 siblings, 0 replies; 8+ messages in thread
From: Greg Kroah-Hartman @ 2012-08-16 17:23 UTC (permalink / raw)
To: Dan Carpenter
Cc: Grant Likely, Rob Herring, Lars-Peter Clausen, linux-kernel,
devicetree-discuss, kernel-janitors
On Fri, Jul 20, 2012 at 06:18:46PM +0300, Dan Carpenter wrote:
> On Fri, Jul 20, 2012 at 08:00:42AM -0700, Greg Kroah-Hartman wrote:
> > On Fri, Jul 20, 2012 at 09:56:23AM +0300, Dan Carpenter wrote:
> > > What prompted this patch is that in dma_pool_create() we call
> > > dev_to_node() before checking whether "dev" is NULL. It looks like
> > > there are places which call dma_pool_create() with a NULL pointer. An
> > > example is in drivers/usb/gadget/amd5536udc.c.
> > >
> > > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > > ---
> > > Static checker fix.
> > >
> > > diff --git a/include/linux/device.h b/include/linux/device.h
> > > index aa7b3b4..c80e7a8d 100644
> > > --- a/include/linux/device.h
> > > +++ b/include/linux/device.h
> > > @@ -714,7 +714,9 @@ int dev_set_name(struct device *dev, const char *name, ...);
> > > #ifdef CONFIG_NUMA
> > > static inline int dev_to_node(struct device *dev)
> > > {
> > > - return dev->numa_node;
> > > + if (dev)
> > > + return dev->numa_node;
> > > + return -1;
> >
> > What happens if this function returns -1? Can the callers properly
> > handle this?
> >
>
> Gar. Now I'm not sure any more.
>
> -1 means no affinity and it's what the dev_to_node() returns if NUMA
> is disabled. But now I think probably it's important to get the
> NUMA node correct in dma_pool_create() so this isn't the right
> answer.
>
> dma_pool_create() is not correct. It has code to handle a NULL
> "dev" pointer, but the dev_to_node() dereference will cause an oops
> before we reach it. I'm think this is a real issue that affects a
> couple drivers. Maybe those people compile without NUMA?
>
> I'm not sure the right fix now.
Ok, I'll drop this one then.
greg k-h
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] driver-core: dev_to_node() should handle NULL pointers
@ 2012-08-16 17:23 ` Greg Kroah-Hartman
0 siblings, 0 replies; 8+ messages in thread
From: Greg Kroah-Hartman @ 2012-08-16 17:23 UTC (permalink / raw)
To: Dan Carpenter
Cc: Grant Likely, Rob Herring, Lars-Peter Clausen, linux-kernel,
devicetree-discuss, kernel-janitors
On Fri, Jul 20, 2012 at 06:18:46PM +0300, Dan Carpenter wrote:
> On Fri, Jul 20, 2012 at 08:00:42AM -0700, Greg Kroah-Hartman wrote:
> > On Fri, Jul 20, 2012 at 09:56:23AM +0300, Dan Carpenter wrote:
> > > What prompted this patch is that in dma_pool_create() we call
> > > dev_to_node() before checking whether "dev" is NULL. It looks like
> > > there are places which call dma_pool_create() with a NULL pointer. An
> > > example is in drivers/usb/gadget/amd5536udc.c.
> > >
> > > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > > ---
> > > Static checker fix.
> > >
> > > diff --git a/include/linux/device.h b/include/linux/device.h
> > > index aa7b3b4..c80e7a8d 100644
> > > --- a/include/linux/device.h
> > > +++ b/include/linux/device.h
> > > @@ -714,7 +714,9 @@ int dev_set_name(struct device *dev, const char *name, ...);
> > > #ifdef CONFIG_NUMA
> > > static inline int dev_to_node(struct device *dev)
> > > {
> > > - return dev->numa_node;
> > > + if (dev)
> > > + return dev->numa_node;
> > > + return -1;
> >
> > What happens if this function returns -1? Can the callers properly
> > handle this?
> >
>
> Gar. Now I'm not sure any more.
>
> -1 means no affinity and it's what the dev_to_node() returns if NUMA
> is disabled. But now I think probably it's important to get the
> NUMA node correct in dma_pool_create() so this isn't the right
> answer.
>
> dma_pool_create() is not correct. It has code to handle a NULL
> "dev" pointer, but the dev_to_node() dereference will cause an oops
> before we reach it. I'm think this is a real issue that affects a
> couple drivers. Maybe those people compile without NUMA?
>
> I'm not sure the right fix now.
Ok, I'll drop this one then.
greg k-h
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-08-16 17:23 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-20 6:56 [patch] driver-core: dev_to_node() should handle NULL pointers Dan Carpenter
2012-07-20 6:56 ` Dan Carpenter
2012-07-20 15:00 ` Greg Kroah-Hartman
2012-07-20 15:00 ` Greg Kroah-Hartman
2012-07-20 15:18 ` Dan Carpenter
2012-07-20 15:18 ` Dan Carpenter
2012-08-16 17:23 ` Greg Kroah-Hartman
2012-08-16 17:23 ` Greg Kroah-Hartman
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.