diff options
author | Daeseok Youn <daeseok.youn@gmail.com> | 2014-06-04 19:08:05 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-06-04 19:54:04 -0400 |
commit | cc6b664aa26de93d9a3f99d4021a8d88b434ed06 (patch) | |
tree | a80c441a939e3a6bd8f9d703b1e89f34fa1ecb6a /mm/dmapool.c | |
parent | 1754e44e8291c92b9d981a6eca59f28dd25f03ab (diff) |
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>
Diffstat (limited to 'mm/dmapool.c')
-rw-r--r-- | mm/dmapool.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/mm/dmapool.c b/mm/dmapool.c index 8058fcd7ae91..a3a1bfe91110 100644 --- a/mm/dmapool.c +++ b/mm/dmapool.c | |||
@@ -170,24 +170,16 @@ struct dma_pool *dma_pool_create(const char *name, struct device *dev, | |||
170 | retval->boundary = boundary; | 170 | retval->boundary = boundary; |
171 | retval->allocation = allocation; | 171 | retval->allocation = allocation; |
172 | 172 | ||
173 | if (dev) { | 173 | INIT_LIST_HEAD(&retval->pools); |
174 | int ret; | ||
175 | 174 | ||
176 | mutex_lock(&pools_lock); | 175 | mutex_lock(&pools_lock); |
177 | if (list_empty(&dev->dma_pools)) | 176 | if (list_empty(&dev->dma_pools) && |
178 | ret = device_create_file(dev, &dev_attr_pools); | 177 | device_create_file(dev, &dev_attr_pools)) { |
179 | else | 178 | kfree(retval); |
180 | ret = 0; | 179 | return NULL; |
181 | /* note: not currently insisting "name" be unique */ | ||
182 | if (!ret) | ||
183 | list_add(&retval->pools, &dev->dma_pools); | ||
184 | else { | ||
185 | kfree(retval); | ||
186 | retval = NULL; | ||
187 | } | ||
188 | mutex_unlock(&pools_lock); | ||
189 | } else | 180 | } else |
190 | INIT_LIST_HEAD(&retval->pools); | 181 | list_add(&retval->pools, &dev->dma_pools); |
182 | mutex_unlock(&pools_lock); | ||
191 | 183 | ||
192 | return retval; | 184 | return retval; |
193 | } | 185 | } |