From patchwork Fri Jan 30 00:00:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 5745971 Return-Path: X-Original-To: patchwork-dmaengine@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0CE8EBF440 for ; Thu, 29 Jan 2015 23:59:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 383392024D for ; Thu, 29 Jan 2015 23:59:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 03DBB20260 for ; Thu, 29 Jan 2015 23:59:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759024AbbA2X7f (ORCPT ); Thu, 29 Jan 2015 18:59:35 -0500 Received: from galahad.ideasonboard.com ([185.26.127.97]:50784 "EHLO galahad.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758935AbbA2X7e (ORCPT ); Thu, 29 Jan 2015 18:59:34 -0500 Received: from avalon.ideasonboard.com (dsl-hkibrasgw3-50ddcc-40.dhcp.inet.fi [80.221.204.40]) by galahad.ideasonboard.com (Postfix) with ESMTPSA id 78C802039F; Fri, 30 Jan 2015 00:59:30 +0100 (CET) From: Laurent Pinchart To: dmaengine@vger.kernel.org Cc: linux-sh@vger.kernel.org Subject: [PATCH v2 1/6] dmaengine: rcar-dmac: Fix uninitialized variable usage Date: Fri, 30 Jan 2015 02:00:08 +0200 Message-Id: <1422576013-7846-2-git-send-email-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 2.0.5 In-Reply-To: <1422576013-7846-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com> References: <1422576013-7846-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com> Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Laurent Pinchart Acked-by: Geert Uytterhoeven --- 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);