Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp28780ybl; Tue, 7 Jan 2020 13:26:50 -0800 (PST) X-Google-Smtp-Source: APXvYqxsEXBjtXa+SXpAUtTK4wDaM2E+J0F9MydxgHNCNNY0kAgoouVUttso62cXfyFmfQ7nkj+J X-Received: by 2002:a05:6808:b37:: with SMTP id t23mr374633oij.149.1578432410020; Tue, 07 Jan 2020 13:26:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578432410; cv=none; d=google.com; s=arc-20160816; b=ldLqMsB52v2eukUmhO4Bto90PnhFqnNxK77HF1RT7Dzu1HLeMAHCLKQ2v3D2xQTSPw CJGKL9wT1QhgLuu+23DeH04Jo5WxpZCzZDQvee3n48Y4k2cykBCnq9Ox7+3zLIhJup2D fuSnpkRhkZWdemLqatcvpTeGcn8F7QCCJdgYcoeU76AgmFAC8SRflKVSbiU+JzvZGCnP hPNMsmwqaXf4lEqb079TerE1ugl35j53v5iLWFoBjDbKvCls9Cxb1Me3zrPmFtJx8M4D uMma+K6nx+ypAS62wKvQUGGvUsoDrUB3+/LZkeWAMFrF3pOAebunQqZsoUukebpKpE5/ kNjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RCVfGVV5E6TbG/stgDOyawJRTsssZb6xDM7YhyHUtwg=; b=UzUgbOC+Snj/RPzaX8wk+PZ00Wl5bmyZ3IBgdNNy/hEu6GZYAe/f0ZAUaYv13WF6Cj 165xSDFIQOTpVnBCwAgJttrQIJzWxxDgddRvJKlZTIJTg7TyeWR5rWhYYNWDnD4jqxL2 Bp9CarA4k/1TroHh9Df1vEHjCSZbK1Y71V96RZX5P4lhJwXgdiNqIErkXd3WN+F3DcVm 5n9F0mp6+WcGDlYBk3IgIM6CQRpg4phK68oCndk5SqcpQnhBjcMlsDrwGjYuwTpZRhKP tOELL78IP9VYIEsFD5rmP4QDzRSD2zOdoSADP6eYnWMqKXHVAo4LH5ioB3aFS5pmHhKo 0Kkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="KOY/03sS"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 19si620504oiq.128.2020.01.07.13.26.30; Tue, 07 Jan 2020 13:26:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="KOY/03sS"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729314AbgAGVZh (ORCPT + 99 others); Tue, 7 Jan 2020 16:25:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:33402 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728192AbgAGU7s (ORCPT ); Tue, 7 Jan 2020 15:59:48 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 898552087F; Tue, 7 Jan 2020 20:59:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578430788; bh=86fnnZvBJPO9es3sKpAHnW2j3Q2FeWk3S/ePdnzjGS4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KOY/03sSZJaKdXFkJkjQL5LetUCDovXr4WiykYD8MyfRu1AZ9iXKQpKU0V0izGIlC 8v8I13loMEkjdb3C4QjhkIo11NKTke9X4OQLDL6+0o684D4CWzv8ecT2oINzDPjSzi +Cgb8v7ayBHbQxK1IMumr7RAJqSmRXrClce3BsWw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kbuild test robot , Lukas Wunner , Vinod Koul Subject: [PATCH 5.4 097/191] dmaengine: Fix access to uninitialized dma_slave_caps Date: Tue, 7 Jan 2020 21:53:37 +0100 Message-Id: <20200107205338.182427130@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200107205332.984228665@linuxfoundation.org> References: <20200107205332.984228665@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lukas Wunner commit 53a256a9b925b47c7e67fc1f16ca41561a7b877c upstream. dmaengine_desc_set_reuse() allocates a struct dma_slave_caps on the stack, populates it using dma_get_slave_caps() and then accesses one of its members. However dma_get_slave_caps() may fail and this isn't accounted for, leading to a legitimate warning of gcc-4.9 (but not newer versions): In file included from drivers/spi/spi-bcm2835.c:19:0: drivers/spi/spi-bcm2835.c: In function 'dmaengine_desc_set_reuse': >> include/linux/dmaengine.h:1370:10: warning: 'caps.descriptor_reuse' is used uninitialized in this function [-Wuninitialized] if (caps.descriptor_reuse) { Fix it, thereby also silencing the gcc-4.9 warning. The issue has been present for 4 years but surfaces only now that the first caller of dmaengine_desc_set_reuse() has been added in spi-bcm2835.c. Another user of reusable DMA descriptors has existed for a while in pxa_camera.c, but it sets the DMA_CTRL_REUSE flag directly instead of calling dmaengine_desc_set_reuse(). Nevertheless, tag this commit for stable in case there are out-of-tree users. Fixes: 272420214d26 ("dmaengine: Add DMA_CTRL_REUSE") Reported-by: kbuild test robot Signed-off-by: Lukas Wunner Cc: stable@vger.kernel.org # v4.3+ Link: https://lore.kernel.org/r/ca92998ccc054b4f2bfd60ef3adbab2913171eac.1575546234.git.lukas@wunner.de Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman --- include/linux/dmaengine.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h @@ -1364,8 +1364,11 @@ static inline int dma_get_slave_caps(str static inline int dmaengine_desc_set_reuse(struct dma_async_tx_descriptor *tx) { struct dma_slave_caps caps; + int ret; - dma_get_slave_caps(tx->chan, &caps); + ret = dma_get_slave_caps(tx->chan, &caps); + if (ret) + return ret; if (caps.descriptor_reuse) { tx->flags |= DMA_CTRL_REUSE;