Re: [PATCH 11/13] staging: most: net: fix race between create/destroy device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, May 12, 2017 at 12:59:59PM +0200, Christian Gromm wrote:
> From: Andrey Shvetsov <andrey.shvetsov@xxxxxx>
> 
> This introduces the kref for the net_dev_context to prevent the
> destruction of the network devices that are in use.
> 
> Each get_net_dev_context is completed with the put_net_dev_context,
> except the function aim_probe_channel that calls one more
> get_net_dev_context or kref_get and the function aim_disconnect_channel
> that calls one more put_net_dev_context.
> 
> Signed-off-by: Andrey Shvetsov <andrey.shvetsov@xxxxxx>
> Signed-off-by: Christian Gromm <christian.gromm@xxxxxxxxxxxxx>
> ---
>  drivers/staging/most/aim-network/networking.c | 92 +++++++++++++++++++++------
>  1 file changed, 72 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/staging/most/aim-network/networking.c b/drivers/staging/most/aim-network/networking.c
> index cbd9500..8cf1c81 100644
> --- a/drivers/staging/most/aim-network/networking.c
> +++ b/drivers/staging/most/aim-network/networking.c
> @@ -21,6 +21,7 @@
>  #include <linux/list.h>
>  #include <linux/wait.h>
>  #include <linux/kobject.h>
> +#include <linux/kref.h>
>  #include "mostcore.h"
>  
>  #define MEP_HDR_LEN 8
> @@ -69,6 +70,7 @@ struct net_dev_context {
>  	struct net_dev_channel rx;
>  	struct net_dev_channel tx;
>  	struct list_head list;
> +	struct kref kref;
>  };
>  
>  static struct list_head net_devices = LIST_HEAD_INIT(net_devices);
> @@ -268,6 +270,26 @@ static void most_nd_setup(struct net_device *dev)
>  	dev->netdev_ops = &most_nd_ops;
>  }
>  
> +static void release_nd(struct kref *kref)
> +{
> +	struct net_dev_context *nd;
> +
> +	nd = container_of(kref, struct net_dev_context, kref);
> +	list_del(&nd->list);

That might delete something off of the list, but it does not free the
structure itself, where is that handled?

Why do you need a reference count for all of this?  Doesn't the
networking core provide you the needed functions for this?

thanks,

greg k-h
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux