Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1520504pxb; Tue, 26 Oct 2021 10:29:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSSqtA1FrUB+0HnLuG6hJdcCXNClJ0IvlAMdY4QuFDbg0g7d7gqyqCdfoAewlEHdXzs0JM X-Received: by 2002:a17:907:6d82:: with SMTP id sb2mr31411804ejc.201.1635269355456; Tue, 26 Oct 2021 10:29:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635269355; cv=none; d=google.com; s=arc-20160816; b=zzAenhEUNjiie4/QXFsJxQHjk8UFBvwN4fqO8njcjv1t1kRoFiZaIWhp5MK1t93o81 ObcKjRtG8klu5ns+ar6iFdab4CjDrFc3+SuWFEQnQAZ3TwkZm4/cySyYJc8+6hyB7sf1 fbXdY/5gbVR3oYtCQuIvc0Y6JaamTDAfOtYoGfuLry5ECuwkEZoBQrnGtD82BnkHhDVQ zdrFnDXmue6AsmRcY0S90s39lEswhv5atAgtMH6CT/FHj/nWv+CegtMZl+k3/IQlTgod vaSi++GgPnlsUkkHUZHiO9XJOtQYMHsZJTe2QVtQIvxfRkByLBOUwcl1WtDc9lq6DDcQ CxdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=9xp0gIi71l5S2aUeGU/Ug2UZYquX3hLjkN8AHlnxHPE=; b=Qb5q/0Kcru4O6DeaAa81MXdk3uViRslt9t2VSQj4fMsOY5Og8jprxs0nObyO2okEVv 5gDSbT2zf9te4DwXn5Ub7PzVaprdXzjOqct3UtAXLiJSj0e9f0X/uMhu9aZyNmgLamou EdNyDCw0bERhdLpUKH0ojdVJg6wQuTp7Oh0cj70qTO9p/sWXH/AUTR9xM2KrkbvtKUVC b0GbrGDrRbxej3hszpMFDuq68ud92jjQHpqq++VrDVQl6PAMoxBRuGRNhnIpCiRuo4Kb 5YmMF1w3hqEBBs0H1NiGmoVoXLaKr7o8t3GHHEyWoRW55suW52eqanHdI8GGFZCXFnTd iZWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="mXG8+T/c"; 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 hr29si3802697ejc.402.2021.10.26.10.28.51; Tue, 26 Oct 2021 10:29:15 -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="mXG8+T/c"; 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 S236362AbhJZOG3 (ORCPT + 99 others); Tue, 26 Oct 2021 10:06:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:39290 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234584AbhJZOG3 (ORCPT ); Tue, 26 Oct 2021 10:06:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4C86960C41; Tue, 26 Oct 2021 14:04:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1635257045; bh=fYdFs1PisYcKFzN6nRtvkLmTckm/NDSJLCk+ti392Ww=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mXG8+T/cQMFHz2x09oPHlhLJhgracMsXllil7jpAGNm37jTEggSQ0Ztv1l/lYpVOD 4yaJbCSkRmUoIkugi192f74I93XiT8A4H0TeeaG6H8kCYjjvDPPlFZNCRN4aP4xROs rVpGprOeNASv0hwRb/TVSFctLrvbJn46AF/iVjWlurWhbbc5k7Cn+8IEkJRPlexUyR muwhqoPHSIKRKQ3wZz3UFmvtgQyjeXYVbd4uVFvAQfxhkx42FKMQmeMGmcPd9KxvdL H0EsnWhxRZJpCcktWb7uSPjIOubg+aBYUIRosyBBEuOE0923IODBggoWuHcwx1rGA8 7VLJb4DOloeOw== Date: Tue, 26 Oct 2021 07:04:00 -0700 From: Nathan Chancellor To: Arnd Bergmann Cc: Sumit Semwal , Christian =?iso-8859-1?Q?K=F6nig?= , Nick Desaulniers , Tvrtko Ursulin , Daniel Vetter , 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: Re: [PATCH] dma-buf: st: fix error handling in test_get_fences() Message-ID: References: <20211026083448.3471055-1-arnd@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211026083448.3471055-1-arnd@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 26, 2021 at 10:34:37AM +0200, Arnd Bergmann wrote: > 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 Reviewed-by: Nathan Chancellor > --- > 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 >