Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1139862pxb; Tue, 26 Oct 2021 03:35:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdV9nkYJC96jO3EC8/bc7OWrfjzPjIebMHR5AwgDZw5SAQ+NoX9WLROJidgn6Swwgs4SH1 X-Received: by 2002:a17:902:bb82:b0:13f:e96a:1706 with SMTP id m2-20020a170902bb8200b0013fe96a1706mr21535058pls.31.1635244544697; Tue, 26 Oct 2021 03:35:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635244544; cv=none; d=google.com; s=arc-20160816; b=GLnWgTRBx05Rc8/BoijRZdYnd1AtiMtHCJCSjP4uxFhr0Rv+6IWtyzrf93jH9Uf3ty Am0VkQhwZcsLp4xkfobAfSpbYgXtOC8bnTDLpTT+KZj3sxTNuHu5xU4hPaEY5noSf6G8 SjBaTCDr0XddkN94+ImiDSA0dRdBqG9H71lcQsigDy2+VLjHrJbqWpgnG399d6IBoYq/ LtPrF0/zrESZJJnnvnoP5utvDK0YV+BPBt7NBU8hdOm7ErKyxCCJzdJMwCzce2zjkGcR uVltV7LW/TiYWcDhIaUBU8NjLyvL+F+kYIbCop8FELDSHxvIOVlKwcwwTXykc9IS/caV k5Mw== 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=vbMrrTjFyfd5jAYEhbYC0Sdh9LfbNu3uTOCBndCL2fY=; b=TQcxKgu7KBwVG5DF0j/0O5NiA5NpBrnckIboNZsprnXSWGVdOr9mlLMknxyD66gnOt JVSTmaOQPEh7LpC6+Y7oN8SGlCVYps/Tw2eI9oBFuBVfXWF8BT14R1ldv3F5U6fWuYWz rWoSDOkaJ7UAD07Rgjpu6VokD0xbDn/vTZBfiGQEa7hQBFDiPVruSZHx7bk96aouimjC qabOO0U01NcKL3j8/bqnjPGXSdom2kUl2AmXVh0pUDwaowqTjnzo8FR87x6dB1jwQq/S UgJqpXok/TU6O4f96ktoZufft2EvVu2xuDfcmJ+d0j3aKXDOwoQi+46A3g2haGJu0GLq G2dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="HfEq/lal"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 w132si27510798pff.278.2021.10.26.03.35.07; Tue, 26 Oct 2021 03:35:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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="HfEq/lal"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S231380AbhJZIhR (ORCPT + 99 others); Tue, 26 Oct 2021 04:37:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:56376 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232001AbhJZIhQ (ORCPT ); Tue, 26 Oct 2021 04:37:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9CDBE60F46; Tue, 26 Oct 2021 08:34:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1635237292; bh=QlPHR7ufXmFxgMpPMQTjAd3avsJoYelK6Xz5gGhBaCQ=; h=From:To:Cc:Subject:Date:From; b=HfEq/lalFrkivwUtuoDMutUydMlIaLLVXIwjXTeD4JMSt35cMz2NlI7ZBa65+NZ3w Dkh/duXWw69za/OMFUt7/AEAegZOP5p9HJrVtiKvUgjpBm6v5s3Rwbp03enNDb8uFc Mrd/FapNtFMPSr/fBt6fPzhGvt0M5jA0/GPCm2ANW1/U+8FTM2z7CE/loCdV2/aAsG S8MSBQBbKKSoZbPBYa65QLJQDa3RHgRtcDb8+7tO3wI9V8D4ndCkAUA2I8/KpMv3v9 ORRQ3+USggkLaEBks7OJqMNY1SNdpizG0fmFq4FivqH13EjMCoibINIaRv2iAVdwx3 h++bIO8NnOOcw== From: Arnd Bergmann To: Sumit Semwal , =?UTF-8?q?Christian=20K=C3=B6nig?= , Nathan Chancellor , Nick Desaulniers , Tvrtko Ursulin , Daniel Vetter Cc: Arnd Bergmann , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH] dma-buf: st: fix error handling in test_get_fences() Date: Tue, 26 Oct 2021 10:34:37 +0200 Message-Id: <20211026083448.3471055-1-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann The new driver incorrectly unwinds after errors, as clang points out: drivers/dma-buf/st-dma-resv.c:295:7: error: variable 'i' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized] if (r) { ^ drivers/dma-buf/st-dma-resv.c:336:9: note: uninitialized use occurs here while (i--) ^ drivers/dma-buf/st-dma-resv.c:295:3: note: remove the 'if' if its condition is always false if (r) { ^~~~~~~~ drivers/dma-buf/st-dma-resv.c:288:6: error: variable 'i' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized] if (r) { ^ drivers/dma-buf/st-dma-resv.c:336:9: note: uninitialized use occurs here while (i--) ^ drivers/dma-buf/st-dma-resv.c:288:2: note: remove the 'if' if its condition is always false if (r) { ^~~~~~~~ drivers/dma-buf/st-dma-resv.c:280:10: note: initialize the variable 'i' to silence this warning int r, i; ^ = 0 Skip cleaning up the bits that have not been allocated at this point. Fixes: 1d51775cd3f5 ("dma-buf: add dma_resv selftest v4") Signed-off-by: Arnd Bergmann --- I'm not familiar with these interfaces, so I'm just guessing where we should jump after an error, please double-check and fix if necessary. --- drivers/dma-buf/st-dma-resv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/dma-buf/st-dma-resv.c b/drivers/dma-buf/st-dma-resv.c index 6f3ba756da3e..bc32b3eedcb6 100644 --- a/drivers/dma-buf/st-dma-resv.c +++ b/drivers/dma-buf/st-dma-resv.c @@ -287,7 +287,7 @@ static int test_get_fences(void *arg, bool shared) r = dma_resv_lock(&resv, NULL); if (r) { pr_err("Resv locking failed\n"); - goto err_free; + goto err_resv; } if (shared) { @@ -295,7 +295,7 @@ static int test_get_fences(void *arg, bool shared) if (r) { pr_err("Resv shared slot allocation failed\n"); dma_resv_unlock(&resv); - goto err_free; + goto err_resv; } dma_resv_add_shared_fence(&resv, f); @@ -336,6 +336,7 @@ static int test_get_fences(void *arg, bool shared) while (i--) dma_fence_put(fences[i]); kfree(fences); +err_resv: dma_resv_fini(&resv); dma_fence_put(f); return r; -- 2.29.2