public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: Andi Shyti <andi.shyti@linux.intel.com>,
	Daniil Dulov <d.dulov@aladdin.ru>
Cc: "Felix Kuehling" <Felix.Kuehling@amd.com>,
	lvc-project@linuxtesting.org, "David Airlie" <airlied@linux.ie>,
	linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org,
	dri-devel@lists.freedesktop.org,
	"Alex Deucher" <alexander.deucher@amd.com>,
	"Oak Zeng" <ozeng@amd.com>,
	"Christian König" <christian.koenig@amd.com>
Subject: Re: [PATCH] drm/amdkfd: Fix potential deallocation of previously deallocated memory.
Date: Tue, 18 Apr 2023 12:07:15 +0200	[thread overview]
Message-ID: <d41669a1-9e18-defb-d0cc-d43d7be7d23e@kernel.org> (raw)
In-Reply-To: <ZD5ZFoEk92MNQpqD@ashyti-mobl2.lan>

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 <d.dulov@aladdin.ru>
>> ---
>>  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


  reply	other threads:[~2023-04-18 10:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-18  6:55 [PATCH] drm/amdkfd: Fix potential deallocation of previously deallocated memory Daniil Dulov
2023-04-18  8:47 ` Andi Shyti
2023-04-18 10:07   ` Krzysztof Kozlowski [this message]
2023-04-18 16:59     ` Andi Shyti
2023-04-18 17:44       ` Andi Shyti
2023-04-18 18:12         ` Daniil Dulov
2023-05-11 11:23         ` [PATCH v2] " Daniil Dulov
2023-05-11 21:12           ` Felix Kuehling

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d41669a1-9e18-defb-d0cc-d43d7be7d23e@kernel.org \
    --to=krzk@kernel.org \
    --cc=Felix.Kuehling@amd.com \
    --cc=airlied@linux.ie \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=andi.shyti@linux.intel.com \
    --cc=christian.koenig@amd.com \
    --cc=d.dulov@aladdin.ru \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=ozeng@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox