All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Dhiraj Shah <find.dhiraj@gmail.com>
To: Dexuan Cui <decui@microsoft.com>
Cc: KY Srinivasan <kys@microsoft.com>,
	Haiyang Zhang <haiyangz@microsoft.com>,
	Stephen Hemminger <sthemmin@microsoft.com>,
	Wei Liu <wei.liu@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Shachar Raindel <shacharr@microsoft.com>,
	Colin Ian King <colin.king@canonical.com>,
	"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] function mana_hwc_create_wq leaks memory
Date: Thu, 10 Jun 2021 20:53:10 +0100	[thread overview]
Message-ID: <98DC11D9-668E-47F2-891C-6F41E70BD5F4@gmail.com> (raw)
In-Reply-To: <BYAPR21MB127087B408352336E0A8BF2ABF359@BYAPR21MB1270.namprd21.prod.outlook.com>

Hi Dexuan,

Thanks for the feedback.

You are right saying ‘mana_hwc_destroy_wq' free’s up the queue. 

However for example if  function 'mana_hwc_alloc_dma_buf' fails it will goto ‘out' and  call  ‘mana_hwc_destroy_wq', the value 'hwc_wq->gdma_wq' is still not assigned at this point. In the  ‘mana_hwc_destroy_wq' function i see it checks for 'hwc_wq->gdma_wq' before calling, ‘mana_gd_destroy_queue', which makes me think queue is still not freed.

Please let me know if i am missing something.

Regards,
/Dhiraj

> On 10 Jun 2021, at 18:28, Dexuan Cui <decui@microsoft.com> wrote:
> 
>> From: Dexuan Cui <decui@microsoft.com>
>> Sent: Thursday, June 10, 2021 10:18 AM
>> ...
>>> diff --git a/drivers/net/ethernet/microsoft/mana/hw_channel.c
>>> b/drivers/net/ethernet/microsoft/mana/hw_channel.c
>>> index 1a923fd99990..4aa4bda518fb 100644
>>> --- a/drivers/net/ethernet/microsoft/mana/hw_channel.c
>>> +++ b/drivers/net/ethernet/microsoft/mana/hw_channel.c
>>> @@ -501,8 +501,10 @@ static int mana_hwc_create_wq(struct
>>> hw_channel_context *hwc,
>>> 	*hwc_wq_ptr = hwc_wq;
>>> 	return 0;
>>> out:
>>> -	if (err)
>>> +	if (err) {
>> 
>> Here the 'err' must be non-zero. Can you please remove this 'if'?
>> 
>>> +		kfree(queue);
>>> 		mana_hwc_destroy_wq(hwc, hwc_wq);
>>> +	}
>>> 	return err;
>>> }
>> 
>> Reviewed-by: Dexuan Cui <decui@microsoft.com>
> 
> Hi Dhiraj,
> I checked the code again and it looks like your patch is actually
> unnecessary as IMO there is no memory leak here: the 'queue'
> pointer is passed to mana_hwc_destroy_wq() as hwc_wq->gdma_wq,
> and is later freed in mana_gd_destroy_queue() ->
> mana_gd_destroy_queue().
> 
> The 'if' test can be removed as the 'err's is always non-zero there.
> 
> Thanks,
> Dexuan


  reply	other threads:[~2021-06-10 19:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-10 15:29 [PATCH] function mana_hwc_create_wq leaks memory Dhiraj Shah
2021-06-10 17:18 ` Dexuan Cui
2021-06-10 17:28   ` Dexuan Cui
2021-06-10 19:53     ` Dhiraj Shah [this message]
2021-06-10 20:03       ` Dexuan Cui

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=98DC11D9-668E-47F2-891C-6F41E70BD5F4@gmail.com \
    --to=find.dhiraj@gmail.com \
    --cc=colin.king@canonical.com \
    --cc=davem@davemloft.net \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=kuba@kernel.org \
    --cc=kys@microsoft.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=shacharr@microsoft.com \
    --cc=sthemmin@microsoft.com \
    --cc=wei.liu@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.