Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1516704

Re: [PATCH] dma-debug: Avoid NULL dereference when checking sync

From Andrew Morton <akpm@linux-foundation.org>
Newsgroups linux.kernel
Subject Re: [PATCH] dma-debug: Avoid NULL dereference when checking sync
Date 2016-11-08 01:40 +0100
Message-ID <sB2Cd-29A-11@gated-at.bofh.it> (permalink)
References <symxr-47I-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, 31 Oct 2016 16:11:41 +0100 Maarten ter Huurne <maarten@treewalker.org> wrote:

> check_sync() calls bucket_find_contain(), which in turn calls
> dma_get_max_seg_size(), which dereferences the device pointer.
> 
> ...
>
> --- a/lib/dma-debug.c
> +++ b/lib/dma-debug.c
> @@ -1223,6 +1223,11 @@ 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);

Well.

a) who is calling check_sync() without having filled in ref.dev? 
   How does this occur?  Is this a bug in the caller?

b) why does check_sync() have a `dev' argument anyway?  Is there any
   situation in which that will differ from ref.dev?

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH] dma-debug: Avoid NULL dereference when checking sync Maarten ter Huurne <maarten@treewalker.org> - 2016-10-31 16:20 +0100
  Re: [PATCH] dma-debug: Avoid NULL dereference when checking sync Andrew Morton <akpm@linux-foundation.org> - 2016-11-08 01:40 +0100

csiph-web