diff options
author | Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> | 2015-04-03 07:20:15 -0400 |
---|---|---|
committer | Vinod Koul <vinod.koul@intel.com> | 2015-04-17 13:58:48 -0400 |
commit | d7d8e892aa6fe280a2e2974d9fd1ec9253ee1a05 (patch) | |
tree | 332e18f29948518da896e908c98d781b7b5b734d /drivers/dma | |
parent | 28591dfdd96c6289aebbf12d8eb4e5dc5ddbde97 (diff) |
dmaengine: usb-dmac: Fix dereferencing freed memory 'desc'
This patch fixes an issue that the usb_dmac_desc_free() is
dereferencing freed memory 'desc' because it uses list_for_each_entry().
This function should use list_for_each_entry_safe().
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Diffstat (limited to 'drivers/dma')
-rw-r--r-- | drivers/dma/sh/usb-dmac.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/dma/sh/usb-dmac.c b/drivers/dma/sh/usb-dmac.c index d5dad98bef0b..f705798ce3eb 100644 --- a/drivers/dma/sh/usb-dmac.c +++ b/drivers/dma/sh/usb-dmac.c | |||
@@ -285,13 +285,13 @@ static int usb_dmac_desc_alloc(struct usb_dmac_chan *chan, unsigned int sg_len, | |||
285 | 285 | ||
286 | static void usb_dmac_desc_free(struct usb_dmac_chan *chan) | 286 | static void usb_dmac_desc_free(struct usb_dmac_chan *chan) |
287 | { | 287 | { |
288 | struct usb_dmac_desc *desc; | 288 | struct usb_dmac_desc *desc, *_desc; |
289 | LIST_HEAD(list); | 289 | LIST_HEAD(list); |
290 | 290 | ||
291 | list_splice_init(&chan->desc_freed, &list); | 291 | list_splice_init(&chan->desc_freed, &list); |
292 | list_splice_init(&chan->desc_got, &list); | 292 | list_splice_init(&chan->desc_got, &list); |
293 | 293 | ||
294 | list_for_each_entry(desc, &list, node) { | 294 | list_for_each_entry_safe(desc, _desc, &list, node) { |
295 | list_del(&desc->node); | 295 | list_del(&desc->node); |
296 | kfree(desc); | 296 | kfree(desc); |
297 | } | 297 | } |