Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1595526ybl; Thu, 5 Dec 2019 04:05:17 -0800 (PST) X-Google-Smtp-Source: APXvYqwckQqnDK7QRn4nP/WPJ6WbFUxM0GCfSvryQEYRQvq1ulXHC6s0IPbc6pk3s1IYM6GZXV4d X-Received: by 2002:a9d:7d9a:: with SMTP id j26mr6560077otn.283.1575547517024; Thu, 05 Dec 2019 04:05:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575547517; cv=none; d=google.com; s=arc-20160816; b=F40wWxSpatQNva/vLwKeufP5Zpa8Dyfn3/a3UjPMoWfiXaTFWmCsV1xXyJoS4qSP4L c3twTFKEYFPt19wits1DudK6Na/QKO0rtQgrsL3NSFP9hGfNJ5lfoULq3fZZzYAEh4K4 Mxi31DcpDD+AyCctEyf7GNlG+Sy1+YvGuLa9c4of2qIWYmqcDcoRZfWpOXf7RE7uE9zE ZtUiNxBXVBY3dZb7uZauJTnlK/2KBcpSOWTP8T1Fdj7p6x2SfuQ0ax0zLsFxGjny223q oKtUOlqwMvFW20y4ewMeNzb3IufCqZL5niVaGDQjas+qh5lvsCpH1FLbXBXqidAh8LT8 JlNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:date:from:references :in-reply-to:message-id; bh=qz5ym6rEHLOUX73nhjR44svjXZGRflqy4n1HaEUWftk=; b=SLe6RMw+ENmDqXWLmhRU+4tH75Fw5m7d/cTuYQWECpblFc/fbuLDk2jabXjEQbfXaC B5zOxvRE6Gz5PCGYaUEAIUXAppkF/3z0z0vCg01aFxRRdiqZpTD2q+qEQVykN5Ztv9yM EKPrG+ns0KH8mCJWIac7aE/ecK/C55cDHvtbeJ57rWKnbmm4gJfBqKBjPOuUzWNY00LH OYTJb87kx66SJatD9aiBgIJ3CUxd0TWAmILAT/xGFPzFzv7RSpOi4DFF69tHI4JPDZHK zYA8C2kQqPyk/e/xe6zqxq6OAeI3BTRXKOfbKIUn/JVpN03DYfQz3VlyxTPuiWvYaIeV Iwlw== ARC-Authentication-Results: i=1; mx.google.com; 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 f19si4848196oti.192.2019.12.05.04.04.57; Thu, 05 Dec 2019 04:05:17 -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; 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 S1729455AbfLEMD1 (ORCPT + 99 others); Thu, 5 Dec 2019 07:03:27 -0500 Received: from mailout3.hostsharing.net ([176.9.242.54]:53339 "EHLO mailout3.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729165AbfLEMD1 (ORCPT ); Thu, 5 Dec 2019 07:03:27 -0500 X-Greylist: delayed 504 seconds by postgrey-1.27 at vger.kernel.org; Thu, 05 Dec 2019 07:03:26 EST Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.hostsharing.net", Issuer "COMODO RSA Domain Validation Secure Server CA" (not verified)) by mailout3.hostsharing.net (Postfix) with ESMTPS id 3A438101E6845; Thu, 5 Dec 2019 12:55:01 +0100 (CET) Received: from localhost (pd95be530.dip0.t-ipconnect.de [217.91.229.48]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by h08.hostsharing.net (Postfix) with ESMTPSA id C877561A257C; Thu, 5 Dec 2019 12:55:00 +0100 (CET) X-Mailbox-Line: From ca92998ccc054b4f2bfd60ef3adbab2913171eac Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: <201912051630.Cb4fFTp2%lkp@intel.com> References: <201912051630.Cb4fFTp2%lkp@intel.com> From: Lukas Wunner Date: Thu, 5 Dec 2019 12:54:49 +0100 Subject: [PATCH] dmaengine: Fix access to uninitialized dma_slave_caps To: Vinod Koul Cc: dmaengine@vger.kernel.org, kbuild-all@lists.01.org, linux-kernel@vger.kernel.org, Mark Brown , Nathan Chancellor Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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+ --- include/linux/dmaengine.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h index 8fcdee1c0cf9..dad4a68fa009 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h @@ -1364,8 +1364,11 @@ static inline int dma_get_slave_caps(struct dma_chan *chan, 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; -- 2.24.0