mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Maarten ter Huurne <maarten@treewalker.org>
To: Dan Williams <dan.j.williams@intel.com>, Jiri Kosina <jkosina@suse.cz>
Cc: linux-kernel@vger.kernel.org,
	Maarten ter Huurne <maarten@treewalker.org>
Subject: [PATCH] dma-debug: Avoid NULL dereference when checking sync
Date: Sun, 28 Feb 2016 16:20:59 +0100	[thread overview]
Message-ID: <1456672859-15521-1-git-send-email-maarten@treewalker.org> (raw)

check_sync() calls bucket_find_contain(), which in turn calls
dma_get_max_seg_size(), which dereferences the device pointer.

Signed-off-by: Maarten ter Huurne <maarten@treewalker.org>
---
 lib/dma-debug.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index 4a1515f..4960402 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -1194,6 +1194,13 @@ static void check_sync(struct device *dev,
 	struct hash_bucket *bucket;
 	unsigned long flags;
 
+	if (!ref->dev) {
+		err_printk(dev, NULL, "DMA-API: device driver passes NULL "
+				"for device to DMA sync function; "
+				"cannot check usage\n");
+		return;
+	}
+
 	bucket = get_hash_bucket(ref, &flags);
 
 	entry = bucket_find_contain(&bucket, ref, &flags);
-- 
2.6.2

             reply	other threads:[~2016-02-28 15:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-28 15:20 Maarten ter Huurne [this message]
2016-10-31 15:11 Maarten ter Huurne
2016-11-08  0:38 ` Andrew Morton

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=1456672859-15521-1-git-send-email-maarten@treewalker.org \
    --to=maarten@treewalker.org \
    --cc=dan.j.williams@intel.com \
    --cc=jkosina@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®