* [PATCH] dmaengine: usb-dmac: Fix dereferencing freed memory 'desc'
@ 2015-04-03 11:20 Yoshihiro Shimoda
2015-04-17 18:11 ` Vinod Koul
0 siblings, 1 reply; 2+ messages in thread
From: Yoshihiro Shimoda @ 2015-04-03 11:20 UTC (permalink / raw)
To: linux-sh
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>
---
This patch is based on slave-dma / for-linus branch.
(commit id = f3070e7efdc37a84fa63cbe84ac4febc87440121)
drivers/dma/sh/usb-dmac.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/dma/sh/usb-dmac.c b/drivers/dma/sh/usb-dmac.c
index d5dad98..f705798 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,
static void usb_dmac_desc_free(struct usb_dmac_chan *chan)
{
- struct usb_dmac_desc *desc;
+ struct usb_dmac_desc *desc, *_desc;
LIST_HEAD(list);
list_splice_init(&chan->desc_freed, &list);
list_splice_init(&chan->desc_got, &list);
- list_for_each_entry(desc, &list, node) {
+ list_for_each_entry_safe(desc, _desc, &list, node) {
list_del(&desc->node);
kfree(desc);
}
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-04-17 18:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-03 11:20 [PATCH] dmaengine: usb-dmac: Fix dereferencing freed memory 'desc' Yoshihiro Shimoda
2015-04-17 18:11 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).