Re: [PATCH] hugetlb: fix locking in region_add,region_cgh,allocate_file_region_entries

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

 



On Fri, Oct 23, 2020 at 09:47:59AM +0200, Laurent Cremmer wrote:
> The third instance spotted by manual examination.

It is friday, I might be overlooking something obvious, so bear with me.

> In static long region_add(...) and static long region_cgh(...) , releasing
> the acquired lock when exiting via their error path was removed.
> This will cause these functions to return with a lock held if they do not
> succeed.

If they do not suceed, it means that allocate_file_region_entries returned
non-zero, which means that we hit:

	spin_unlock(&resv->lock);
	for (i = 0; i < to_allocate; i++) {
		trg = kmalloc(sizeof(*trg), GFP_KERNEL);
		if (!trg)
			goto out_of_memory;
		list_add(&trg->link, &allocated_regions);
	 }

So, we do spin_unlock before jumping to out_of_memory.

> A a new function allocate_file_region_entries was also introduced  that
> must be called with a lock held and returned with the lock held.
> However the lock is temporarily released during processing but will not
> be reacquired on error.

As stated above, region_add/region_chr exit immediately on allocate_file_region_entries
failure, so it does not need to acquire the lock.


-- 
Oscar Salvador
SUSE L3




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux