public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hv: vmbus_free_channels(): remove the redundant free_channel()
@ 2015-04-09  6:13 Dexuan Cui
  2015-04-09  9:07 ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Dexuan Cui @ 2015-04-09  6:13 UTC (permalink / raw)
  To: gregkh, linux-kernel, driverdev-devel, olaf, apw, jasowang, kys,
	vkuznets, dan.carpenter
  Cc: haiyangz

free_channel() has been invoked in
vmbus_remove() -> hv_process_channel_removal(), or vmbus_remove() ->
... -> vmbus_close_internal() -> hv_process_channel_removal().

We also change to use list_for_each_entry_safe(), because the entry
is removed in hv_process_channel_removal().

Thank Dan Carpenter for finding the issue!

Signed-off-by: Dexuan Cui <decui@microsoft.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: K. Y. Srinivasan <kys@microsoft.com>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
---
 drivers/hv/channel_mgmt.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 0eeb1b3..865a3af 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -212,11 +212,16 @@ void hv_process_channel_removal(struct vmbus_channel *channel, u32 relid)
 
 void vmbus_free_channels(void)
 {
-	struct vmbus_channel *channel;
+	struct vmbus_channel *channel, *tmp;
+
+	list_for_each_entry_safe(channel, tmp, &vmbus_connection.chn_list,
+		listentry) {
+		/* if we don't set rescind to true, vmbus_close_internal()
+		 * won't invoke hv_process_channel_removal().
+		 */
+		channel->rescind = true;
 
-	list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
 		vmbus_device_unregister(channel->device_obj);
-		free_channel(channel);
 	}
 }
 
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] hv: vmbus_free_channels(): remove the redundant free_channel()
  2015-04-09  6:13 [PATCH] hv: vmbus_free_channels(): remove the redundant free_channel() Dexuan Cui
@ 2015-04-09  9:07 ` Greg KH
  2015-04-09  9:15   ` Dexuan Cui
  0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2015-04-09  9:07 UTC (permalink / raw)
  To: Dexuan Cui
  Cc: linux-kernel, driverdev-devel, olaf, apw, jasowang, kys, vkuznets,
	dan.carpenter, haiyangz

On Wed, Apr 08, 2015 at 11:13:47PM -0700, Dexuan Cui wrote:
> free_channel() has been invoked in
> vmbus_remove() -> hv_process_channel_removal(), or vmbus_remove() ->
> ... -> vmbus_close_internal() -> hv_process_channel_removal().
> 
> We also change to use list_for_each_entry_safe(), because the entry
> is removed in hv_process_channel_removal().
> 
> Thank Dan Carpenter for finding the issue!
> 
> Signed-off-by: Dexuan Cui <decui@microsoft.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Cc: K. Y. Srinivasan <kys@microsoft.com>
> Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
> ---
>  drivers/hv/channel_mgmt.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
> index 0eeb1b3..865a3af 100644
> --- a/drivers/hv/channel_mgmt.c
> +++ b/drivers/hv/channel_mgmt.c
> @@ -212,11 +212,16 @@ void hv_process_channel_removal(struct vmbus_channel *channel, u32 relid)
>  
>  void vmbus_free_channels(void)
>  {
> -	struct vmbus_channel *channel;
> +	struct vmbus_channel *channel, *tmp;
> +
> +	list_for_each_entry_safe(channel, tmp, &vmbus_connection.chn_list,
> +		listentry) {

Horrid indentation, never put continuations on a 1 tab stop location,
you can't read this properly, right?

> +		/* if we don't set rescind to true, vmbus_close_internal()
> +		 * won't invoke hv_process_channel_removal().
> +		 */
> +		channel->rescind = true;

You are changing the logic here, right?  Why do you now need the _safe()
call if you aren't freeing anything?

confused,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] hv: vmbus_free_channels(): remove the redundant free_channel()
  2015-04-09  9:07 ` Greg KH
@ 2015-04-09  9:15   ` Dexuan Cui
  2015-04-09  9:21     ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Dexuan Cui @ 2015-04-09  9:15 UTC (permalink / raw)
  To: Greg KH
  Cc: linux-kernel@vger.kernel.org,
	driverdev-devel@linuxdriverproject.org, olaf@aepfle.de,
	apw@canonical.com, jasowang@redhat.com, KY Srinivasan,
	vkuznets@redhat.com, dan.carpenter@oracle.com, Haiyang Zhang

> -----Original Message-----
> From: Greg KH [mailto:gregkh@linuxfoundation.org]
> Sent: Thursday, April 9, 2015 17:07
> To: Dexuan Cui
> Cc: linux-kernel@vger.kernel.org; driverdev-devel@linuxdriverproject.org;
> olaf@aepfle.de; apw@canonical.com; jasowang@redhat.com; KY Srinivasan;
> vkuznets@redhat.com; dan.carpenter@oracle.com; Haiyang Zhang
> Subject: Re: [PATCH] hv: vmbus_free_channels(): remove the redundant
> free_channel()
> 
> On Wed, Apr 08, 2015 at 11:13:47PM -0700, Dexuan Cui wrote:
> > free_channel() has been invoked in
> > vmbus_remove() -> hv_process_channel_removal(), or vmbus_remove() ->
> > ... -> vmbus_close_internal() -> hv_process_channel_removal().
> >
> > We also change to use list_for_each_entry_safe(), because the entry
> > is removed in hv_process_channel_removal().
> >
> > Thank Dan Carpenter for finding the issue!
> >
> > Signed-off-by: Dexuan Cui <decui@microsoft.com>
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > Cc: K. Y. Srinivasan <kys@microsoft.com>
> > Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
> > ---
> >  drivers/hv/channel_mgmt.c | 11 ++++++++---
> >  1 file changed, 8 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
> > index 0eeb1b3..865a3af 100644
> > --- a/drivers/hv/channel_mgmt.c
> > +++ b/drivers/hv/channel_mgmt.c
> > @@ -212,11 +212,16 @@ void hv_process_channel_removal(struct
> vmbus_channel *channel, u32 relid)
> >
> >  void vmbus_free_channels(void)
> >  {
> > -	struct vmbus_channel *channel;
> > +	struct vmbus_channel *channel, *tmp;
> > +
> > +	list_for_each_entry_safe(channel, tmp, &vmbus_connection.chn_list,
> > +		listentry) {
> 
> Horrid indentation, never put continuations on a 1 tab stop location,
> you can't read this properly, right?
> 
> > +		/* if we don't set rescind to true, vmbus_close_internal()
> > +		 * won't invoke hv_process_channel_removal().
> > +		 */
> > +		channel->rescind = true;
> 
> You are changing the logic here, right?  Why do you now need the _safe()
> call if you aren't freeing anything?
> 
> confused,
> 
> greg k-h

Hi Greg,
vmbus_device_unregister() invokes device_unregister() -> vmbus_remove() ->
hv_process_channel_removal() -- in this function, we remove the entry from
the list:
list_del(&channel->listentry)
and we run free_channel(channel).

Thanks,
-- Dexuan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] hv: vmbus_free_channels(): remove the redundant free_channel()
  2015-04-09  9:15   ` Dexuan Cui
@ 2015-04-09  9:21     ` Greg KH
  2015-04-09  9:27       ` Dexuan Cui
  0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2015-04-09  9:21 UTC (permalink / raw)
  To: Dexuan Cui
  Cc: linux-kernel@vger.kernel.org,
	driverdev-devel@linuxdriverproject.org, olaf@aepfle.de,
	apw@canonical.com, jasowang@redhat.com, KY Srinivasan,
	vkuznets@redhat.com, dan.carpenter@oracle.com, Haiyang Zhang

On Thu, Apr 09, 2015 at 09:15:30AM +0000, Dexuan Cui wrote:
> > -----Original Message-----
> > From: Greg KH [mailto:gregkh@linuxfoundation.org]
> > Sent: Thursday, April 9, 2015 17:07
> > To: Dexuan Cui
> > Cc: linux-kernel@vger.kernel.org; driverdev-devel@linuxdriverproject.org;
> > olaf@aepfle.de; apw@canonical.com; jasowang@redhat.com; KY Srinivasan;
> > vkuznets@redhat.com; dan.carpenter@oracle.com; Haiyang Zhang
> > Subject: Re: [PATCH] hv: vmbus_free_channels(): remove the redundant
> > free_channel()
> > 
> > On Wed, Apr 08, 2015 at 11:13:47PM -0700, Dexuan Cui wrote:
> > > free_channel() has been invoked in
> > > vmbus_remove() -> hv_process_channel_removal(), or vmbus_remove() ->
> > > ... -> vmbus_close_internal() -> hv_process_channel_removal().
> > >
> > > We also change to use list_for_each_entry_safe(), because the entry
> > > is removed in hv_process_channel_removal().
> > >
> > > Thank Dan Carpenter for finding the issue!
> > >
> > > Signed-off-by: Dexuan Cui <decui@microsoft.com>
> > > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > > Cc: K. Y. Srinivasan <kys@microsoft.com>
> > > Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
> > > ---
> > >  drivers/hv/channel_mgmt.c | 11 ++++++++---
> > >  1 file changed, 8 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
> > > index 0eeb1b3..865a3af 100644
> > > --- a/drivers/hv/channel_mgmt.c
> > > +++ b/drivers/hv/channel_mgmt.c
> > > @@ -212,11 +212,16 @@ void hv_process_channel_removal(struct
> > vmbus_channel *channel, u32 relid)
> > >
> > >  void vmbus_free_channels(void)
> > >  {
> > > -	struct vmbus_channel *channel;
> > > +	struct vmbus_channel *channel, *tmp;
> > > +
> > > +	list_for_each_entry_safe(channel, tmp, &vmbus_connection.chn_list,
> > > +		listentry) {
> > 
> > Horrid indentation, never put continuations on a 1 tab stop location,
> > you can't read this properly, right?
> > 
> > > +		/* if we don't set rescind to true, vmbus_close_internal()
> > > +		 * won't invoke hv_process_channel_removal().
> > > +		 */
> > > +		channel->rescind = true;
> > 
> > You are changing the logic here, right?  Why do you now need the _safe()
> > call if you aren't freeing anything?
> > 
> > confused,
> > 
> > greg k-h
> 
> Hi Greg,
> vmbus_device_unregister() invokes device_unregister() -> vmbus_remove() ->
> hv_process_channel_removal() -- in this function, we remove the entry from
> the list:
> list_del(&channel->listentry)
> and we run free_channel(channel).

What is "this function" referring to here?  vmbus_free_channels()?

still confused.

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] hv: vmbus_free_channels(): remove the redundant free_channel()
  2015-04-09  9:21     ` Greg KH
@ 2015-04-09  9:27       ` Dexuan Cui
  0 siblings, 0 replies; 5+ messages in thread
From: Dexuan Cui @ 2015-04-09  9:27 UTC (permalink / raw)
  To: Greg KH
  Cc: linux-kernel@vger.kernel.org,
	driverdev-devel@linuxdriverproject.org, olaf@aepfle.de,
	apw@canonical.com, jasowang@redhat.com, KY Srinivasan,
	vkuznets@redhat.com, dan.carpenter@oracle.com, Haiyang Zhang



Thanks,
-- Dexuan

> -----Original Message-----
> From: Greg KH [mailto:gregkh@linuxfoundation.org]
> Sent: Thursday, April 9, 2015 17:22
> To: Dexuan Cui
> Cc: linux-kernel@vger.kernel.org; driverdev-devel@linuxdriverproject.org;
> olaf@aepfle.de; apw@canonical.com; jasowang@redhat.com; KY Srinivasan;
> vkuznets@redhat.com; dan.carpenter@oracle.com; Haiyang Zhang
> Subject: Re: [PATCH] hv: vmbus_free_channels(): remove the redundant
> free_channel()
> 
> On Thu, Apr 09, 2015 at 09:15:30AM +0000, Dexuan Cui wrote:
> > > -----Original Message-----
> > > From: Greg KH [mailto:gregkh@linuxfoundation.org]
> > > Sent: Thursday, April 9, 2015 17:07
> > > To: Dexuan Cui
> > > Cc: linux-kernel@vger.kernel.org; driverdev-devel@linuxdriverproject.org;
> > > olaf@aepfle.de; apw@canonical.com; jasowang@redhat.com; KY Srinivasan;
> > > vkuznets@redhat.com; dan.carpenter@oracle.com; Haiyang Zhang
> > > Subject: Re: [PATCH] hv: vmbus_free_channels(): remove the redundant
> > > free_channel()
> > >
> > > On Wed, Apr 08, 2015 at 11:13:47PM -0700, Dexuan Cui wrote:
> > > > free_channel() has been invoked in
> > > > vmbus_remove() -> hv_process_channel_removal(), or vmbus_remove() ->
> > > > ... -> vmbus_close_internal() -> hv_process_channel_removal().
> > > >
> > > > We also change to use list_for_each_entry_safe(), because the entry
> > > > is removed in hv_process_channel_removal().
> > > >
> > > > Thank Dan Carpenter for finding the issue!
> > > >
> > > > Signed-off-by: Dexuan Cui <decui@microsoft.com>
> > > > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > > > Cc: K. Y. Srinivasan <kys@microsoft.com>
> > > > Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
> > > > ---
> > > >  drivers/hv/channel_mgmt.c | 11 ++++++++---
> > > >  1 file changed, 8 insertions(+), 3 deletions(-)
> > > >
> > > > diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
> > > > index 0eeb1b3..865a3af 100644
> > > > --- a/drivers/hv/channel_mgmt.c
> > > > +++ b/drivers/hv/channel_mgmt.c
> > > > @@ -212,11 +212,16 @@ void hv_process_channel_removal(struct
> > > vmbus_channel *channel, u32 relid)
> > > >
> > > >  void vmbus_free_channels(void)
> > > >  {
> > > > -	struct vmbus_channel *channel;
> > > > +	struct vmbus_channel *channel, *tmp;
> > > > +
> > > > +	list_for_each_entry_safe(channel, tmp, &vmbus_connection.chn_list,
> > > > +		listentry) {
> > >
> > > Horrid indentation, never put continuations on a 1 tab stop location,
> > > you can't read this properly, right?
> > >
> > > > +		/* if we don't set rescind to true, vmbus_close_internal()
> > > > +		 * won't invoke hv_process_channel_removal().
> > > > +		 */
> > > > +		channel->rescind = true;
> > >
> > > You are changing the logic here, right?  Why do you now need the _safe()
> > > call if you aren't freeing anything?
> > >
> > > confused,
> > >
> > > greg k-h
> >
> > Hi Greg,
> > vmbus_device_unregister() invokes device_unregister() -> vmbus_remove() ->
> > hv_process_channel_removal() -- in this function, we remove the entry from
> > the list:
> > list_del(&channel->listentry)
> > and we run free_channel(channel).
> 
> What is "this function" referring to here?  vmbus_free_channels()?
> 
> still confused.
> 
> greg k-h

"this function" means hv_process_channel_removal().

-- Dexuan

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-04-09  9:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-09  6:13 [PATCH] hv: vmbus_free_channels(): remove the redundant free_channel() Dexuan Cui
2015-04-09  9:07 ` Greg KH
2015-04-09  9:15   ` Dexuan Cui
2015-04-09  9:21     ` Greg KH
2015-04-09  9:27       ` Dexuan Cui

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox