提交 2912282c 编写于 作者: J Jiri Slaby 提交者: Greg Kroah-Hartman

USB: make usb_buffer_map_sg consistent with doc

usb_buffer_map_sg should return negative on error according to
its documentation. But dma_map_sg returns 0 on error. Take this
into account and return -ENOMEM in such situation.

While at it, return -EINVAL instead of -1 when wrong input is
passed in.

If this wasn't done, usb_sg_* operations used after usb_sg_init
which returned 0 may cause oopses/deadlocks since we don't init
structures/entries, esp. completion and status entry.
Signed-off-by: NJiri Slaby <jirislaby@gmail.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 a448c9d8
...@@ -914,11 +914,11 @@ int usb_buffer_map_sg(const struct usb_device *dev, int is_in, ...@@ -914,11 +914,11 @@ int usb_buffer_map_sg(const struct usb_device *dev, int is_in,
|| !(bus = dev->bus) || !(bus = dev->bus)
|| !(controller = bus->controller) || !(controller = bus->controller)
|| !controller->dma_mask) || !controller->dma_mask)
return -1; return -EINVAL;
/* FIXME generic api broken like pci, can't report errors */ /* FIXME generic api broken like pci, can't report errors */
return dma_map_sg(controller, sg, nents, return dma_map_sg(controller, sg, nents,
is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE); is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE) ? : -ENOMEM;
} }
EXPORT_SYMBOL_GPL(usb_buffer_map_sg); EXPORT_SYMBOL_GPL(usb_buffer_map_sg);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册