Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1336052pxb; Tue, 26 Oct 2021 07:14:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJ1EFoMsqb0sbwnUEeTnc5f3k0O2p/sL0NuH7Ts0WbRX7vCIoohGJMZBeuSOF7vkJnanHv X-Received: by 2002:a17:90a:b795:: with SMTP id m21mr28881209pjr.143.1635257673862; Tue, 26 Oct 2021 07:14:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1635257673; cv=pass; d=google.com; s=arc-20160816; b=hCLG9NjBhUSnSvPuTo0DMS9ubsremsuCNXq+byr2mEpCw6DUZyLX2XaI6W7tuqJ0e5 hegkAm2wc8xpLgOav/loaI3O7lZQmsF5skDDKIZmFi7p7myMLGDV9PilD+XG/NJ8DF00 abPN2rgPgbHrUUXohqXdE/HR68EMvD2ZNpvQZ0Repp9HnvNx7rTbNm6m3tQil0sNNIiz mUnq0RxVyXj5MER0QKr9wZMUkNhoj7IPDUKgnv+N999XUottWaJVLCipqFuoHllyNU2U /q+MqXL+ktGloP0kTzBaDjRlVNMHcJMH73CMLh/eJ4rEAeim2FMqXO95rTHl+PdqNjqj 8PdA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-language :content-transfer-encoding:in-reply-to:user-agent:date:message-id :from:references:cc:to:subject:dkim-signature; bh=HRkZ6p0OVu8VflWHz4Yo6TyKH+sSKcF+7wv5545bjgs=; b=0lh50g96Y/nQzK4wRRx6SrngrgfDCk93DOkxIU1doOS9zraVO0lrqJb/kIv4uWWYGm emzUdMYF4cKXsj8H0NKHVgKz/6vdph9jZ5sRMQRa/evpSKT3Zf/wF3MgMajGlJxKsZmo 1DCEgZLW3+ZIv/3Oyp/GJJgQI9cIX85iTN14SMeJWeaeDasiqafdGugu1+XkzzxovsMT VPkf6igUy4zsSlf2Qic0t56YvWM0+fyoIhKMitQGrg77qe7x03n7beSmfGKlEaDzWYCr jrnJF0E4I4LJNHZrNS7olAocKpBkRbYIangEEWWsNNI3HpV2gGbtT3ANy/NPBQbbE3o+ MJ9w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Y7RtBvZg; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o16si855752pjt.136.2021.10.26.07.14.18; Tue, 26 Oct 2021 07:14:33 -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=@amd.com header.s=selector1 header.b=Y7RtBvZg; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235286AbhJZK60 (ORCPT + 99 others); Tue, 26 Oct 2021 06:58:26 -0400 Received: from mail-dm6nam12on2085.outbound.protection.outlook.com ([40.107.243.85]:43520 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235364AbhJZK6U (ORCPT ); Tue, 26 Oct 2021 06:58:20 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ja4ZZbvEvapjnMrvWLVlEGNBrEV3UkJBX9O5ODkMokkF8F0harBPZTeHTAygnoAJB2gZpx5MS97d9l5qRu2qIGnFTeN0ONCMedObjAIsczD1gKuuGAzFxs0Ts4cSW85n79fL2j+m16/4FR4Ra1lAnmqS3/6+VK1VMr9eJKq80zeDprnbTcxLAYFdZYnR/y1zrnN0QI3x5yPnm6HIEL0cDK2FtCye6rLDbogRw4LoUrv16XIll/Reb8zbg9sc5v2sR39GmEMFtUtgeovea976Zc11VnXiK70gahZFRxCfzU1I+Z8CG6zmt/pKxe8f0zhqhVjti+7uhuBKBvCHJasrDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HRkZ6p0OVu8VflWHz4Yo6TyKH+sSKcF+7wv5545bjgs=; b=g5hZSqa8eBl0f6x1FamVzln+68Rx61H5dJyfXLLQs9v5rk9YagHCLPa8j4BwGn9Hq/eEqLPlxr493itwCo/M61Mg6UlRpsu1JUWTD3zFc3NrLGZ+2dDbVpYmdOHZBQyPMu/SLfz+n9xzkFuRE4/aSc6TVefr2fkKapyqBvJ+37OQtz2mKqIIhtoE/1tKyw9qMYUh+KAtYFefQTCtB69wWXyT4GmS3TMXzRov4waysHFmaFgjoCh0kTi47QJnS5EvIM1Gl61PGEI9l7QraxRixWm5JZRj4fqjU1nXgbBV+uluWg2zuyFNzM4HCcBx1yWcHOseGuy/QuT2gqFp57W5Mw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HRkZ6p0OVu8VflWHz4Yo6TyKH+sSKcF+7wv5545bjgs=; b=Y7RtBvZgWSNae33JsuX1cSY/j7NlnX62+JBR4CwBer0lzwhvm8WSquZKkQBxpuYbjbgqxhsBdxLtyDV0P1TSKIDDt7TQ1y3n7DkIIy4UD2akBPrVEUAW06vRaI7FQ92E9liw3swSllhaFtujPKPTuQcma695CaTaesfBjurMnw0= Authentication-Results: lists.linux.dev; dkim=none (message not signed) header.d=none;lists.linux.dev; dmarc=none action=none header.from=amd.com; Received: from MWHPR1201MB0192.namprd12.prod.outlook.com (2603:10b6:301:5a::14) by MW3PR12MB4570.namprd12.prod.outlook.com (2603:10b6:303:5f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16; Tue, 26 Oct 2021 10:55:55 +0000 Received: from MWHPR1201MB0192.namprd12.prod.outlook.com ([fe80::55c7:6fc9:b2b1:1e6a]) by MWHPR1201MB0192.namprd12.prod.outlook.com ([fe80::55c7:6fc9:b2b1:1e6a%10]) with mapi id 15.20.4628.020; Tue, 26 Oct 2021 10:55:55 +0000 Subject: Re: [PATCH] dma-buf: st: fix error handling in test_get_fences() To: Arnd Bergmann , Sumit Semwal , 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 References: <20211026083448.3471055-1-arnd@kernel.org> From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: <52f6a48a-cd94-da21-2cda-300fd1f78a44@amd.com> Date: Tue, 26 Oct 2021 12:55:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 In-Reply-To: <20211026083448.3471055-1-arnd@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-ClientProxiedBy: AM5PR04CA0018.eurprd04.prod.outlook.com (2603:10a6:206:1::31) To MWHPR1201MB0192.namprd12.prod.outlook.com (2603:10b6:301:5a::14) MIME-Version: 1.0 Received: from [IPv6:2a02:908:1252:fb60:4969:85a5:71fe:e4fa] (2a02:908:1252:fb60:4969:85a5:71fe:e4fa) by AM5PR04CA0018.eurprd04.prod.outlook.com (2603:10a6:206:1::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.18 via Frontend Transport; Tue, 26 Oct 2021 10:55:52 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 114a9b08-ef83-401a-e35f-08d9986f2eec X-MS-TrafficTypeDiagnostic: MW3PR12MB4570: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HUoHRuHN7YKa1Y9NMAA2iqxVtWZPSI5ZsZgCtpms7llnHfHJ3eoYfuuYtjfyyPAYHZ2RJtPqFUCgR0OOlQPx6PEferWoglat91iwsvmsKOahsC4DU8C3chCG5u1p954Nq8c5eUF3ZFBsK1h+hVjFCCJH9Ncgt2i13lW50DozFM703VIAPvTxFMeH7BSRspiWa4o+flbVPYRrLNKrKU5ROHE5p9fJCtRHMVCiPGb8deX5l4SNH0NiUsfagJ4yQ6cezvC2ET37cRt+YgWygcT6njZ5i+PePaVNjDMbqrEYUXm95zymjY9TY9Qtwj+dTPA8HIe4lMWmVeXY57s1O8fYV9NIUTsPM97rN6VMGt2ulNelVVkLgzToDtnIgq7RRZ6uAYM1wTPLXi+z6aWBNRMreJ2RE79ubIAGytC2vlI+AzZwgPj6XsHOVNOuzH5pVi+nLYB7zVT5UsiUZPSjAHkRGiX6RJ9DI2gvGi6Rk/Vj8s2GUPS4dXMQxt6AupojlEXE61MVft9+uHCY+5a5DCG1ZF97+etj0Dt8lSYtmyCIP/GA1UFccvhg+tA/usPHpVnLuYaX9zb50fXmLKJNZkIx8BxKgvGr2CSKp70L0J4c0sTkM/9m8F0fOhBTuYGrP2/HklYR3moUH0ovkEsuEw6+ujum9tobKz1z14aKRXxXRMustCms/ankMLehMxrCQT8mptex+3HcT3KJVX12gygZsBM/zunkNpv4j4nRB+eYZYyea50uKozM7kjopQmOzPh0 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR1201MB0192.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(7416002)(66946007)(83380400001)(316002)(4326008)(8676002)(6486002)(508600001)(5660300002)(2906002)(66556008)(186003)(8936002)(86362001)(38100700002)(110136005)(36756003)(6666004)(31686004)(31696002)(2616005)(66476007)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?SE5oK3l4RXV0U3BtQUFsaCtldnZ3c0pxMHQzMzNDSTlJQXQ1WTd1WERNM3BH?= =?utf-8?B?Mm5jZWJ3MWF4QUhGQldrR0gzdFZ4cDFxRWdjYjY2YVZHVkdLaWFuWXh4dXVY?= =?utf-8?B?OXV0SnNqbDcwMGRaTnFxeHRyelFkQzY2b0dDVUhvcUlsSHFXTVFJeTE5bkk1?= =?utf-8?B?SFhoRVo4b3Y3ZDlKV3VISlpmdzBHaU9ZMmxrem9NU1MxTWV0dU1FVmJFb2pr?= =?utf-8?B?WG9aZHR4dEM2M0MwUzNzWmIrUGFSL1k3MWpsaXB4MGNMZWRrR2IvTTN4Q3Zy?= =?utf-8?B?OEpIZVFheWFycFY1SXhoaTVVS0phRUpVUzFYaFMwUUtNU2w4MmdoTUZ5enh1?= =?utf-8?B?dWw0YW1XWDBqbDJhT3RUb1habXV0e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XIk3V6YvvN6BpI441zyKY=3D?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 114a9b08-ef83-401a-e35f-08d9986f2eec X-MS-Exchange-CrossTenant-AuthSource: MWHPR1201MB0192.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2021 10:55:54.8732 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ZTmjoxK5oy8VSX1xnElsDtC95Zvoi4PshM+1sZSiRKoI8pC/fu0qYsN/Cq8lK6eO X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4570 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 26.10.21 um 10:34 schrieb Arnd Bergmann: > 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 already send out a patch to fix this up, but forgot to fix both gotos. Going to add my rb and using that one here instead. Thanks, Christian. > --- > 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;