From: Haneen Mohammed <hamohammed.sa@gmail.com>
To: outreachy-kernel@googlegroups.com
Subject: [PATCH] Staging: vt6655: Add check dma_mapping_error
Date: Thu, 11 Feb 2016 21:34:40 +0300 [thread overview]
Message-ID: <20160211183440.GA11731@haneenVB> (raw)
This patch checks for dma_mapping_error() after using dma_map_single.
If the dma map fails we release skb buff allocated by dev_alloc_skb() to
avoid possible causes of resource leak.
Signed-off-by: Haneen Mohammed <hamohammed.sa@gmail.com>
---
drivers/staging/vt6655/device_main.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
index ad0fb84..8a1ed62 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -742,6 +742,11 @@ static bool device_alloc_rx_buf(struct vnt_private *priv,
dma_map_single(&priv->pcid->dev,
skb_put(rd_info->skb, skb_tailroom(rd_info->skb)),
priv->rx_buf_sz, DMA_FROM_DEVICE);
+ if (dma_mapping_error(&priv->pcid->dev, rd_info->skb_dma)) {
+ dev_kfree_skb(rd_info->skb);
+ rd_info->skb = NULL;
+ return false;
+ }
*((unsigned int *)&rd->rd0) = 0; /* FIX cast */
--
1.9.1
next reply other threads:[~2016-02-11 18:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-11 18:34 Haneen Mohammed [this message]
2016-02-12 4:00 ` [Outreachy kernel] [PATCH] Staging: vt6655: Add check dma_mapping_error Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160211183440.GA11731@haneenVB \
--to=hamohammed.sa@gmail.com \
--cc=outreachy-kernel@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.