[Devel] [PATCH rh7] ve/drivers: Do not forget to release mismatched device found

Konstantin Khorenko khorenko at virtuozzo.com
Fri Jul 17 08:55:56 PDT 2015


Volodya, please review.

--
Best regards,

Konstantin Khorenko,
Virtuozzo Linux Kernel Team

On 07/09/2015 12:49 PM, Cyrill Gorcunov wrote:
> Upon call of device_destroy_namespace we walk over namespace devices
> looking for one which match on both device maj/min and VE itself,
> but the thing is that if device belong to another VE we continue
> iteration with never released get_device call.
> 
> Thus rework the walking routine -- remember the last reference
> and put it once new iteration is done.
> 
> https://jira.sw.ru/browse/PSBM-34777
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov at virtuozzo.com>
> CC: Andrey Vagin <avagin at virtuozzo.com>
> CC: Vladimir Davydov <vdavydov at virtuozzo.com>
> CC: Konstantin Khorenko <khorenko at virtuozzo.com>
> ---
> 
> I'm not sure at moment if this indeed address the bug
> mentioned gonna test it but seems we're having this problem
> anyway and need to fix it.
> 
>  drivers/base/core.c |   13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)
> 
> Index: linux-pcs7.git/drivers/base/core.c
> ===================================================================
> --- linux-pcs7.git.orig/drivers/base/core.c
> +++ linux-pcs7.git/drivers/base/core.c
> @@ -1838,15 +1838,12 @@ EXPORT_SYMBOL_GPL(device_destroy);
>  
>  void device_destroy_namespace(struct class *class, dev_t devt, void *ns)
>  {
> -	struct device *dev = NULL;
> +	struct device *dev = NULL, *prev = NULL;
>  
> -	for (;;) {
> -		dev = class_find_device(class, dev, &devt, __match_devt);
> -		if (!dev)
> -			break;
> -		if (!class->namespace ||
> -		    (class->namespace(dev) == ns))
> -			break;
> +	for (dev = class_find_device(class, dev, &devt, __match_devt);
> +	     dev && (class->namespace && class->namespace(dev) != ns);) {
> +		prev = dev, dev = class_find_device(class, dev, &devt, __match_devt);
> +		put_device(prev);
>  	}
>  
>  	if (dev) {
> _______________________________________________
> Devel mailing list
> Devel at openvz.org
> https://lists.openvz.org/mailman/listinfo/devel
> 



More information about the Devel mailing list