提交 ff487fb7 编写于 作者: J Jeff Garzik 提交者: Dan Williams

drivers/dma: handle sysfs errors

From: Jeff Garzik <jeff@garzik.org>
Signed-off-by: NJeff Garzik <jeff@garzik.org>
Signed-off-by: NChris Leech <christopher.leech@intel.com>
上级 000725d5
...@@ -316,7 +316,7 @@ EXPORT_SYMBOL(dma_async_client_chan_request); ...@@ -316,7 +316,7 @@ EXPORT_SYMBOL(dma_async_client_chan_request);
int dma_async_device_register(struct dma_device *device) int dma_async_device_register(struct dma_device *device)
{ {
static int id; static int id;
int chancnt = 0; int chancnt = 0, rc;
struct dma_chan* chan; struct dma_chan* chan;
if (!device) if (!device)
...@@ -338,8 +338,15 @@ int dma_async_device_register(struct dma_device *device) ...@@ -338,8 +338,15 @@ int dma_async_device_register(struct dma_device *device)
snprintf(chan->class_dev.class_id, BUS_ID_SIZE, "dma%dchan%d", snprintf(chan->class_dev.class_id, BUS_ID_SIZE, "dma%dchan%d",
device->dev_id, chan->chan_id); device->dev_id, chan->chan_id);
rc = class_device_register(&chan->class_dev);
if (rc) {
chancnt--;
free_percpu(chan->local);
chan->local = NULL;
goto err_out;
}
kref_get(&device->refcount); kref_get(&device->refcount);
class_device_register(&chan->class_dev);
} }
mutex_lock(&dma_list_mutex); mutex_lock(&dma_list_mutex);
...@@ -349,6 +356,17 @@ int dma_async_device_register(struct dma_device *device) ...@@ -349,6 +356,17 @@ int dma_async_device_register(struct dma_device *device)
dma_chans_rebalance(); dma_chans_rebalance();
return 0; return 0;
err_out:
list_for_each_entry(chan, &device->channels, device_node) {
if (chan->local == NULL)
continue;
kref_put(&device->refcount, dma_async_device_cleanup);
class_device_unregister(&chan->class_dev);
chancnt--;
free_percpu(chan->local);
}
return rc;
} }
EXPORT_SYMBOL(dma_async_device_register); EXPORT_SYMBOL(dma_async_device_register);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册