* [PATCH] dmaengine: rcar-dmac: Fix uninitialized variable usage
@ 2015-01-08 16:29 Laurent Pinchart
2015-01-21 22:16 ` Laurent Pinchart
2015-02-11 1:39 ` Vinod Koul
0 siblings, 2 replies; 3+ messages in thread
From: Laurent Pinchart @ 2015-01-08 16:29 UTC (permalink / raw)
To: linux-sh
The desc variable is used uninitialized in the rcar_dmac_desc_get() and
rcar_dmac_xfer_chunk_get() functions if descriptors need to be
allocated. Fix it.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
drivers/dma/sh/rcar-dmac.c | 69 +++++++++++++++++++++-------------------------
1 file changed, 31 insertions(+), 38 deletions(-)
diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index 29dd09ad41ff..8367578bac63 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -549,26 +549,22 @@ static struct rcar_dmac_desc *rcar_dmac_desc_get(struct rcar_dmac_chan *chan)
spin_lock_irq(&chan->lock);
- do {
- if (list_empty(&chan->desc.free)) {
- /*
- * No free descriptors, allocate a page worth of them
- * and try again, as someone else could race us to get
- * the newly allocated descriptors. If the allocation
- * fails return an error.
- */
- spin_unlock_irq(&chan->lock);
- ret = rcar_dmac_desc_alloc(chan, GFP_NOWAIT);
- if (ret < 0)
- return NULL;
- spin_lock_irq(&chan->lock);
- continue;
- }
+ while (list_empty(&chan->desc.free)) {
+ /*
+ * No free descriptors, allocate a page worth of them and try
+ * again, as someone else could race us to get the newly
+ * allocated descriptors. If the allocation fails return an
+ * error.
+ */
+ spin_unlock_irq(&chan->lock);
+ ret = rcar_dmac_desc_alloc(chan, GFP_NOWAIT);
+ if (ret < 0)
+ return NULL;
+ spin_lock_irq(&chan->lock);
+ }
- desc = list_first_entry(&chan->desc.free, struct rcar_dmac_desc,
- node);
- list_del(&desc->node);
- } while (!desc);
+ desc = list_first_entry(&chan->desc.free, struct rcar_dmac_desc, node);
+ list_del(&desc->node);
spin_unlock_irq(&chan->lock);
@@ -621,26 +617,23 @@ rcar_dmac_xfer_chunk_get(struct rcar_dmac_chan *chan)
spin_lock_irq(&chan->lock);
- do {
- if (list_empty(&chan->desc.chunks_free)) {
- /*
- * No free descriptors, allocate a page worth of them
- * and try again, as someone else could race us to get
- * the newly allocated descriptors. If the allocation
- * fails return an error.
- */
- spin_unlock_irq(&chan->lock);
- ret = rcar_dmac_xfer_chunk_alloc(chan, GFP_NOWAIT);
- if (ret < 0)
- return NULL;
- spin_lock_irq(&chan->lock);
- continue;
- }
+ while (list_empty(&chan->desc.chunks_free)) {
+ /*
+ * No free descriptors, allocate a page worth of them and try
+ * again, as someone else could race us to get the newly
+ * allocated descriptors. If the allocation fails return an
+ * error.
+ */
+ spin_unlock_irq(&chan->lock);
+ ret = rcar_dmac_xfer_chunk_alloc(chan, GFP_NOWAIT);
+ if (ret < 0)
+ return NULL;
+ spin_lock_irq(&chan->lock);
+ }
- chunk = list_first_entry(&chan->desc.chunks_free,
- struct rcar_dmac_xfer_chunk, node);
- list_del(&chunk->node);
- } while (!chunk);
+ chunk = list_first_entry(&chan->desc.chunks_free,
+ struct rcar_dmac_xfer_chunk, node);
+ list_del(&chunk->node);
spin_unlock_irq(&chan->lock);
--
Regards,
Laurent Pinchart
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] dmaengine: rcar-dmac: Fix uninitialized variable usage
2015-01-08 16:29 [PATCH] dmaengine: rcar-dmac: Fix uninitialized variable usage Laurent Pinchart
@ 2015-01-21 22:16 ` Laurent Pinchart
2015-02-11 1:39 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Laurent Pinchart @ 2015-01-21 22:16 UTC (permalink / raw)
To: linux-sh
Hi Vinod,
Could you please apply this patch to your tree for v3.20 ?
On Thursday 08 January 2015 18:29:25 Laurent Pinchart wrote:
> The desc variable is used uninitialized in the rcar_dmac_desc_get() and
> rcar_dmac_xfer_chunk_get() functions if descriptors need to be
> allocated. Fix it.
>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
> drivers/dma/sh/rcar-dmac.c | 69 +++++++++++++++++++------------------------
> 1 file changed, 31 insertions(+), 38 deletions(-)
>
> diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
> index 29dd09ad41ff..8367578bac63 100644
> --- a/drivers/dma/sh/rcar-dmac.c
> +++ b/drivers/dma/sh/rcar-dmac.c
> @@ -549,26 +549,22 @@ static struct rcar_dmac_desc
> *rcar_dmac_desc_get(struct rcar_dmac_chan *chan)
>
> spin_lock_irq(&chan->lock);
>
> - do {
> - if (list_empty(&chan->desc.free)) {
> - /*
> - * No free descriptors, allocate a page worth of them
> - * and try again, as someone else could race us to get
> - * the newly allocated descriptors. If the allocation
> - * fails return an error.
> - */
> - spin_unlock_irq(&chan->lock);
> - ret = rcar_dmac_desc_alloc(chan, GFP_NOWAIT);
> - if (ret < 0)
> - return NULL;
> - spin_lock_irq(&chan->lock);
> - continue;
> - }
> + while (list_empty(&chan->desc.free)) {
> + /*
> + * No free descriptors, allocate a page worth of them and try
> + * again, as someone else could race us to get the newly
> + * allocated descriptors. If the allocation fails return an
> + * error.
> + */
> + spin_unlock_irq(&chan->lock);
> + ret = rcar_dmac_desc_alloc(chan, GFP_NOWAIT);
> + if (ret < 0)
> + return NULL;
> + spin_lock_irq(&chan->lock);
> + }
>
> - desc = list_first_entry(&chan->desc.free, struct rcar_dmac_desc,
> - node);
> - list_del(&desc->node);
> - } while (!desc);
> + desc = list_first_entry(&chan->desc.free, struct rcar_dmac_desc, node);
> + list_del(&desc->node);
>
> spin_unlock_irq(&chan->lock);
>
> @@ -621,26 +617,23 @@ rcar_dmac_xfer_chunk_get(struct rcar_dmac_chan *chan)
>
> spin_lock_irq(&chan->lock);
>
> - do {
> - if (list_empty(&chan->desc.chunks_free)) {
> - /*
> - * No free descriptors, allocate a page worth of them
> - * and try again, as someone else could race us to get
> - * the newly allocated descriptors. If the allocation
> - * fails return an error.
> - */
> - spin_unlock_irq(&chan->lock);
> - ret = rcar_dmac_xfer_chunk_alloc(chan, GFP_NOWAIT);
> - if (ret < 0)
> - return NULL;
> - spin_lock_irq(&chan->lock);
> - continue;
> - }
> + while (list_empty(&chan->desc.chunks_free)) {
> + /*
> + * No free descriptors, allocate a page worth of them and try
> + * again, as someone else could race us to get the newly
> + * allocated descriptors. If the allocation fails return an
> + * error.
> + */
> + spin_unlock_irq(&chan->lock);
> + ret = rcar_dmac_xfer_chunk_alloc(chan, GFP_NOWAIT);
> + if (ret < 0)
> + return NULL;
> + spin_lock_irq(&chan->lock);
> + }
>
> - chunk = list_first_entry(&chan->desc.chunks_free,
> - struct rcar_dmac_xfer_chunk, node);
> - list_del(&chunk->node);
> - } while (!chunk);
> + chunk = list_first_entry(&chan->desc.chunks_free,
> + struct rcar_dmac_xfer_chunk, node);
> + list_del(&chunk->node);
>
> spin_unlock_irq(&chan->lock);
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] dmaengine: rcar-dmac: Fix uninitialized variable usage
2015-01-08 16:29 [PATCH] dmaengine: rcar-dmac: Fix uninitialized variable usage Laurent Pinchart
2015-01-21 22:16 ` Laurent Pinchart
@ 2015-02-11 1:39 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2015-02-11 1:39 UTC (permalink / raw)
To: linux-sh
On Thu, Jan 08, 2015 at 06:29:25PM +0200, Laurent Pinchart wrote:
> The desc variable is used uninitialized in the rcar_dmac_desc_get() and
> rcar_dmac_xfer_chunk_get() functions if descriptors need to be
> allocated. Fix it.
Applied, thanks
--
~Vinod
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-02-11 1:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-08 16:29 [PATCH] dmaengine: rcar-dmac: Fix uninitialized variable usage Laurent Pinchart
2015-01-21 22:16 ` Laurent Pinchart
2015-02-11 1:39 ` 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).