mm/dmapool.c: remove redundant NULL check for dev in dma_pool_create()

"dev" cannot be NULL because it is already checked before calling
dma_pool_create().

If dev ever was NULL, the code would oops in dev_to_node() after enabling
CONFIG_NUMA.

It is possible that some driver is using dev==NULL and has never been run
on a NUMA machine.  Such a driver is probably outdated, possibly buggy and
will need some attention if it starts triggering NULL derefs.

Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Daeseok Youn 2014-06-04 16:08:05 -07:00 committed by Linus Torvalds
parent 1754e44e82
commit cc6b664aa2

View File

@ -170,24 +170,16 @@ struct dma_pool *dma_pool_create(const char *name, struct device *dev,
retval->boundary = boundary; retval->boundary = boundary;
retval->allocation = allocation; retval->allocation = allocation;
if (dev) { INIT_LIST_HEAD(&retval->pools);
int ret;
mutex_lock(&pools_lock); mutex_lock(&pools_lock);
if (list_empty(&dev->dma_pools)) if (list_empty(&dev->dma_pools) &&
ret = device_create_file(dev, &dev_attr_pools); device_create_file(dev, &dev_attr_pools)) {
else kfree(retval);
ret = 0; return NULL;
/* note: not currently insisting "name" be unique */
if (!ret)
list_add(&retval->pools, &dev->dma_pools);
else {
kfree(retval);
retval = NULL;
}
mutex_unlock(&pools_lock);
} else } else
INIT_LIST_HEAD(&retval->pools); list_add(&retval->pools, &dev->dma_pools);
mutex_unlock(&pools_lock);
return retval; return retval;
} }