lkml.org 
[lkml]   [2012]   [Jul]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch] driver-core: dev_to_node() should handle NULL pointers
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


\
 
 \ /
  Last update: 2012-07-20 17:41    [W:0.044 / U:0.320 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site