[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20121105123738.0a0490a7.akpm@linux-foundation.org>
Date: Mon, 5 Nov 2012 12:37:38 -0800
From: Andrew Morton <akpm@...ux-foundation.org>
To: Xi Wang <xi.wang@...il.com>
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm: fix NULL checking in dma_pool_create()
On Mon, 5 Nov 2012 01:46:36 -0500
Xi Wang <xi.wang@...il.com> wrote:
> First, `dev' is dereferenced in dev_to_node(dev), suggesting that it
> must be non-null. Later `dev' is checked against NULL, suggesting
> the opposite. This patch adds a NULL check before its use.
>
> ...
>
> @@ -159,7 +160,9 @@ struct dma_pool *dma_pool_create(const char *name, struct device *dev,
> return NULL;
> }
>
> - retval = kmalloc_node(sizeof(*retval), GFP_KERNEL, dev_to_node(dev));
> + node = dev ? dev_to_node(dev) : -1;
> +
> + retval = kmalloc_node(sizeof(*retval), GFP_KERNEL, node);
> if (!retval)
> return retval;
Well, the dma_pool_create() kerneldoc does not describe dev==NULL to be
acceptable usage and given the lack of oops reports, we can assume that
no code is calling this function with dev==NULL.
So I think we can just remove the code which handles dev==NULL?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists