From patchwork Tue Oct 26 08:34:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 516177 Delivered-To: patch@linaro.org Received: by 2002:ac0:c404:0:0:0:0:0 with SMTP id t4csp53018imj; Tue, 26 Oct 2021 01:34:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZYWxCb4oPSIiZh9gmWqYi4fVvskHp3pS9dmO60lb7sV5zkYPwfTrm7KyOepYzA5nv2CMB X-Received: by 2002:a17:90a:fd84:: with SMTP id cx4mr24507174pjb.217.1635237295373; Tue, 26 Oct 2021 01:34:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635237295; cv=none; d=google.com; s=arc-20160816; b=GmeCdVgxBTtEi3FYdIiymrFGr3iY3T4eAFxB9hZU2hvloKdky+5YO19+iMT5Ic9n+7 A7Q0BXYsNQyFDFxsFXn2qIaweupmSudqPjyks935K7NwfWsDn8rbiH7qXaYJMNcnV2ln LYt6AKJdijbmrMFusQ9IlZHXHDCkW4Q2SLkjduP6EH33gdRZxG6lBdYcgV23uS5aS3+l 1aydfkTe/Eg/W/QVV7LrNM1Z5zH3n7O7+Fijjgqx5VnBL1Frstkm7feEwVztXaAn95gM GyoP3UsNpSHUSj66wkJAi8u0lUozysf5D+mIXpl7z1FPYLv6c92Yg8duhMJ5rQFhgsj2 Lp2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :delivered-to; bh=vbMrrTjFyfd5jAYEhbYC0Sdh9LfbNu3uTOCBndCL2fY=; b=MLqCIwCuibvYTSmKSTSmGKlLg5Zp40LRt47Al0zcbhtpL0ZR5Jwj2yULJfcFOldDMN qNAnpDMVdOj2+LlWtZGsvOoHH5CLAnquDjYxthNCmkSQboiAyfnUWsxf26KGe6wGExY6 7WY73H9wEoA5enjrFInDD/Rv4ZoOozCaZjoi+UeFJf0+UAMvVrACt5MVOBA3PmBOfN3R dApHSZq1v9mE1QuH941YWZBYB8u7DImzC2zB4wyxOq/emcRtsZmyKRQuy1dLPajHpA5U nOr8V9awvkdGtFLNqLKhcUQJWU4MR4FkqtqqGP8XWFNfHOOkMfQ5PFI3fQwPPcvSXEJ5 IZNg== 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: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id b15si12279017pgw.483.2021.10.26.01.34.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Oct 2021 01:34:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="HfEq/lal"; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5D7786E4B7; Tue, 26 Oct 2021 08:34:54 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id 01A586E486 for ; Tue, 26 Oct 2021 08:34:53 +0000 (UTC) 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_K=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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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(-) -- 2.29.2 Reviewed-by: Nathan Chancellor 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;