Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp5171926rwe; Tue, 18 Apr 2023 03:11:29 -0700 (PDT) X-Google-Smtp-Source: AKy350YV548z5VNogKFB9GglYw2Gz8OT/crpiz0uonU/9CH4ITn1EitS1d/W1Txq9RQRTTJqcx0c X-Received: by 2002:a05:6a20:918a:b0:ec:86a7:4fa5 with SMTP id v10-20020a056a20918a00b000ec86a74fa5mr21184571pzd.30.1681812689077; Tue, 18 Apr 2023 03:11:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681812689; cv=none; d=google.com; s=arc-20160816; b=Qf7iUem6tQyhVKYyp8zhiYc8/j6tI7Pn9/VmlxFmApbEdr6UuK3zv1vDZxAqwQFW1o FNmlqyUWvWnR/vMByS1eDLEXTwSNPFpmiz9N1YRULkH8Je0vYuukRiQ9uCB9fmBrkIcY DPm8VnicZekWf+0nP0/lr5G//yNQWFa1mgYKHGr+Gd18KXqmvjfQVcx0ljgLO4ULP12I 0NsgV26M3AZmxme38/S2ou1RqWjxXsHwICpYqj6OEbQktL0h14TcSDZ6ox8m6kQERQZW Q5HOoZHOhkqADDqDOYleWniP78Hge+HslTDf5U5CeIMfrsdiDC0zpT+jCDMWYIizysYD VIfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=k81et0sReSsabgNePoZRxnCWIqOXH+gSHYcaH+C1H6U=; b=0pyJioTBVmcDO6MfNSVDd1dZOhjz66g8wkkYb1eN9Qt9M0xnOQ28mAfDkusO0dDnFZ Bwl/+TAkuyRhdOQNZb7VV29xwIruznCnXKMS1/d9e0wDCRjmK+5mFVw5p8Cgz1HlgOBc kHg6huUpUjG2p4wMuqbSRlROKpsNquzLLwTaXrNiNyoZHKmdWd/KKrmJxGOIIOPSv4g0 hd8VedRhvAoR2OOgcQ2i85mwi0HGI3k3wBTbpdnj2quyETZ+ywuw2Lyfrn/VCMpIXmUF FiBwWW1oilcyO6P2bvRd1/ZZWjexudrinadPoEI5kl5BAA7R0DLuAmYe9yoK7x/HFvAM IRxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LXRNfcbn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r13-20020aa7988d000000b0063b897210a4si6349275pfl.14.2023.04.18.03.11.16; Tue, 18 Apr 2023 03:11:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LXRNfcbn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230307AbjDRKHY (ORCPT + 99 others); Tue, 18 Apr 2023 06:07:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229597AbjDRKHW (ORCPT ); Tue, 18 Apr 2023 06:07:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5AA944AE for ; Tue, 18 Apr 2023 03:07:21 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 407F3626E4 for ; Tue, 18 Apr 2023 10:07:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40DFCC433EF; Tue, 18 Apr 2023 10:07:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681812440; bh=R/KFdzXCgnetVU5Nex15rrtlAf5YzHR9xzJSb9o4Y2Y=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=LXRNfcbnzbR/JRb37sh45HIKT358NsFj41T9b15kR2krRa+JbvD70anAojbmzyq90 C5BOw6QjNuWpdUoBSu4grqRa+C5kfVGd0oVbD9r/5cC7fB/47IOm2Jt3SKbU0MwEzJ AWRoFZKbphe2b3sOoFwrXei9lmV9atifBODRhrQ0yWa/3JGvymVIJ1g8o+zyIj+3v7 3CHRCfc//HX5Uw4HgbwL0kM2Ul8fUhEJYOUZ/+6p2aWIWyEcw5Ur1+9oDM8K5AKtO0 gMeuGXFeRHKsOtO9i7m1OmEej4oLZQLykAH6XkY2oKpIJLBrJsjD2K5W3tV/OGquxT KRoxLu9xKqceA== Message-ID: Date: Tue, 18 Apr 2023 12:07:15 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH] drm/amdkfd: Fix potential deallocation of previously deallocated memory. Content-Language: en-US To: Andi Shyti , Daniil Dulov Cc: Felix Kuehling , lvc-project@linuxtesting.org, David Airlie , linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Alex Deucher , Oak Zeng , =?UTF-8?Q?Christian_K=c3=b6nig?= References: <20230418065521.453001-1-d.dulov@aladdin.ru> From: Krzysztof Kozlowski In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 18/04/2023 10:47, Andi Shyti wrote: > Hi Daniil, > > On Mon, Apr 17, 2023 at 11:55:21PM -0700, Daniil Dulov wrote: >> Pointer mqd_mem_obj can be deallocated in kfd_gtt_sa_allocate(). >> The function then returns non-zero value, which causes the second deallocation. >> >> Found by Linux Verification Center (linuxtesting.org) with SVACE. >> >> Fixes: d1f8f0d17d40 ("drm/amdkfd: Move non-sdma mqd allocation out of init_mqd") >> Signed-off-by: Daniil Dulov >> --- >> drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c >> index 3b6f5963180d..bce11c5b07d6 100644 >> --- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c >> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c >> @@ -119,7 +119,8 @@ static struct kfd_mem_obj *allocate_mqd(struct kfd_dev *kfd, >> } >> >> if (retval) { >> - kfree(mqd_mem_obj); >> + if (mqd_mem_obj) >> + kfree(mqd_mem_obj); > > I think this is not needed. kfree() returns immediately if > mqd_mem_obj is NULL. > Yep, the tool has to be fixed because such patch is just misleading. However different point - the commit description actually describes entirely different case: double free. Maybe the issue is true, just the fix is wrong? Best regards, Krzysztof