From patchwork Sun Jan 3 13:57:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 356149 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp14269310jai; Sun, 3 Jan 2021 05:58:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJwn+maA3i7jOBDIEPF11LjwvkEOn/eWz+rgEkFBqS3eUS6JtVio6/OLHoY/qOy7v+d+AgDq X-Received: by 2002:a17:906:16d6:: with SMTP id t22mr63285488ejd.154.1609682330608; Sun, 03 Jan 2021 05:58:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609682330; cv=none; d=google.com; s=arc-20160816; b=s7D5ArKDi4MAtLclGg2OL7MBKuNb3/HMLofjZhndIr/r3Wsi7cLn3qUVKyjOY659wD HxOfvdSDp6ThXXfHnT1z8hrrl91a0HQDYfFDXlkKx3QqBMWA61cDDLn7nvuexrCzb9IE OhEYPXg2JORZqZMtdv58kizKRqC85nB0eC2+rS3OttKz8G6fp1tpnQ2UdJNS+UbQ1zk1 ghZo1AvvjdHSJgsldwlv41zdjhdb2wFg+L/dcEDBmMFPTCf3aNnJTMzIsh/OlpwBu7wR htCJMerxRBqgGzDpTrq895Dr32wvdydrqTx6Mryp0+Petb4d9VDcYPfznsy2WN4ZHfT9 lvPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=nUaeCVvPyxqq2tIcRFXyg5s7A4HR5VbLUc6UTtUx4os=; b=ufRXpp62qYD0PFTPAtiS9/CDz2yChdeaIQaUGYgJ66k+OUGu0dimSdJUpnIK63X6jH VxJyKSCPKBJr6wqW01HlaP07gsToA9O+1J9uH32PzDI2Kb2KGxgr8Q6vXVAIb2a3aI2x 5Mq23I9DINa0uiPU+jq1kqavEhrKWGWhzMB8nVb2lLFYcsJHR9je76eJdUKqi9PnA3iK frHmafsbILTaf9XOA4T99RB0DHe25pbhgntgbV1Lp9w6Rs4m/jBUCyvpJ1T8HdTs4n3+ pbkNBRoEnr+8eBpT7JVyO+LwAoeZkpEnYtY7Hh25LhsYNRbwJiRPV/BOvlMgpenU7ga9 T7hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OJjp4WMn; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id no7si26631001ejb.586.2021.01.03.05.58.50; Sun, 03 Jan 2021 05:58:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OJjp4WMn; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726969AbhACN6X (ORCPT + 15 others); Sun, 3 Jan 2021 08:58:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:35262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726129AbhACN6X (ORCPT ); Sun, 3 Jan 2021 08:58:23 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 632DE208C7; Sun, 3 Jan 2021 13:57:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1609682262; bh=w6s5kcebAimhgTVacPtTiUtHsUatLmTZP8NLc4JsnK4=; h=From:To:Cc:Subject:Date:From; b=OJjp4WMn408IY0DKvguUQR/l+RzDopHMYgkO326QJjAwxCrvQcSEMEbN5lVDulUqy qqLYkxW6kHrhJbdrkDpQr/VwVH1sdnXBZNXVs+34m2ccbRtVOZa362iV/v+i3FLQUh YTJArNRhdXBW0G4PSHssB1Uk7lRrCiHA/EPSdfK5kWESbtv1eX+o1wQB6aalORtbVx PAyPQtFhCIupKKirFvSW1L4Wpj+x+8zJHzFTlUWhGOmBYOcbY/NZVUQXTDPfxpceQN MSTK8dZz/AkvmX5/mV3KtblrTYnlnM6RxXsgBrV0fxwpIZiYbdL0RgclXxhK+hNLjS VQYGxV8y4LHKg== From: Arnd Bergmann To: Andy Gross , Bjorn Andersson , Vinod Koul Cc: Arnd Bergmann , Dan Williams , linux-arm-msm@vger.kernel.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] dmaengine: qcom: fix gpi undefined behavior Date: Sun, 3 Jan 2021 14:57:29 +0100 Message-Id: <20210103135738.3741123-1-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Arnd Bergmann gcc points out an incorrect error handling loop: drivers/dma/qcom/gpi.c: In function 'gpi_ch_init': drivers/dma/qcom/gpi.c:1254:15: error: iteration 2 invokes undefined behavior [-Werror=aggressive-loop-optimizations] 1254 | struct gpii *gpii = gchan->gpii; | ^~~~ drivers/dma/qcom/gpi.c:1951:2: note: within this loop 1951 | for (i = i - 1; i >= 0; i++) { | ^~~ Change the loop to correctly walk backwards through the initialized fields rather than off into the woods. Fixes: 5d0c3533a19f ("dmaengine: qcom: Add GPI dma driver") Signed-off-by: Arnd Bergmann --- drivers/dma/qcom/gpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.29.2 diff --git a/drivers/dma/qcom/gpi.c b/drivers/dma/qcom/gpi.c index 8d39d3e24686..9c211104ddbf 100644 --- a/drivers/dma/qcom/gpi.c +++ b/drivers/dma/qcom/gpi.c @@ -1948,7 +1948,7 @@ static int gpi_ch_init(struct gchan *gchan) return ret; error_start_chan: - for (i = i - 1; i >= 0; i++) { + for (i = i - 1; i >= 0; i--) { gpi_stop_chan(&gpii->gchan[i]); gpi_send_cmd(gpii, gchan, GPI_CH_CMD_RESET); }