Commit 786ae133 authored by Randy Dunlap's avatar Randy Dunlap Committed by Linus Torvalds

lib: fix test_hmm.c reference after free

Coccinelle scripts report the following errors:

  lib/test_hmm.c:523:20-26: ERROR: reference preceded by free on line 521
  lib/test_hmm.c:524:21-27: ERROR: reference preceded by free on line 521
  lib/test_hmm.c:523:28-35: ERROR: devmem is NULL but dereferenced.
  lib/test_hmm.c:524:29-36: ERROR: devmem is NULL but dereferenced.

Fix these by using the local variable 'res' instead of devmem.

Link: http://lkml.kernel.org/r/c845c158-9c65-9665-0d0b-00342846dd07@infradead.orgSigned-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
Reviewed-by: default avatarRalph Campbell <rcampbell@nvidia.com>
Cc: Jérôme Glisse <jglisse@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 9277f833
...@@ -520,8 +520,7 @@ static bool dmirror_allocate_chunk(struct dmirror_device *mdevice, ...@@ -520,8 +520,7 @@ static bool dmirror_allocate_chunk(struct dmirror_device *mdevice,
err_free: err_free:
kfree(devmem); kfree(devmem);
err_release: err_release:
release_mem_region(devmem->pagemap.res.start, release_mem_region(res->start, resource_size(res));
resource_size(&devmem->pagemap.res));
err: err:
mutex_unlock(&mdevice->devmem_lock); mutex_unlock(&mdevice->devmem_lock);
return false; return false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment