Re: [PATCH] mm/mmap: undo ->mmap() when arch_validate_flags() fails

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

 



> ---
>  mm/mmap.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/mmap.c b/mm/mmap.c
> index 9d780f415be3..36c08e2c78da 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -1797,7 +1797,7 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
>  	if (!arch_validate_flags(vma->vm_flags)) {
>  		error = -EINVAL;
>  		if (file)
> -			goto unmap_and_free_vma;
> +			goto close_and_free_vma;
>  		else
>  			goto free_vma;
>  	}
> @@ -1844,6 +1844,9 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
>  
>  	return addr;
>  
> +close_and_free_vma:
> +	if (vma->vm_ops && vma->vm_ops->close)
> +		vma->vm_ops->close(vma);
>  unmap_and_free_vma:
>  	fput(vma->vm_file);
>  	vma->vm_file = NULL;
> -- 
> 2.38.0.rc1.362.ged0d419d3c-goog
> 

Sorry for the late reply, I was out of the office.

The analysis looks good and I agree that open() should have a matching
close() call in the unwinding.

Reviewed-by: Liam Howlett <liam.howlett@xxxxxxxxxx>



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux