lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Thu, 21 Aug 2014 19:01:21 +0800
From:	Xiang Wang <wangxfdu@...il.com>
To:	Vinod Koul <vinod.koul@...el.com>,
	Dan Williams <dan.j.williams@...el.com>,
	<dmaengine@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
	<cxie4@...vell.com>, <wangxfdu@...il.com>
CC:	Xiang Wang <wangx@...vell.com>
Subject: [PATCH] dmaengine: increase privatecnt in dma_get_any_slave_channel

From: Xiang Wang <wangx@...vell.com>

There might be such calling sequence for dma channel:
1. register dma device
dma_async_device_register
  -> if (dma_has_cap(DMA_PRIVATE, device->cap_mask))
  	device->privatecnt++;

2. request channel
dma_request_slave_channel
  -> of_dma_request_slave_channel
    -> of_dma_xlate
      -> dma_get_any_slave_channel in dma drivers
note that device->privatecnt is not changed during this.

3. release channel
dma_release_channel
  -> if (--chan->device->privatecnt == 0)
		dma_cap_clear(DMA_PRIVATE,
		chan->device->cap_mask);

So if we request a channel then release it, DMA_PRIVATE will
be cleared unexpectedly. In this patch, we increase privatecnt
in step 2 just like what __dma_request_channel does.

Signed-off-by: Xiang Wang <wangx@...vell.com>
---
 drivers/dma/dmaengine.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index ed610b4..01bb372 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -557,6 +557,9 @@ struct dma_chan *dma_get_any_slave_channel(struct dma_device *device)
 		}
 	}
 
+	if (chan && dma_has_cap(DMA_PRIVATE, device->cap_mask))
+		device->privatecnt++;
+
 	mutex_unlock(&dma_list_mutex);
 
 	return chan;
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ