linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Ralph Campbell <rcampbell@nvidia.com>
To: Randy Dunlap <rdunlap@infradead.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linux MM <linux-mm@kvack.org>
Cc: "Jérôme Glisse" <jglisse@redhat.com>
Subject: Re: [PATCH -next] lib: fix test_hmm.c reference after free
Date: Thu, 18 Jun 2020 09:21:57 -0700	[thread overview]
Message-ID: <fae8934b-7300-27ff-e18e-6db413b9ea53@nvidia.com> (raw)
In-Reply-To: <c845c158-9c65-9665-0d0b-00342846dd07@infradead.org>


On 6/17/20 10:31 PM, Randy Dunlap wrote:
> From: Randy Dunlap <rdunlap@infradead.org>
> 
> 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.
> 
> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
> Cc: Jérôme Glisse <jglisse@redhat.com>
> Cc: linux-mm@kvack.org
> Cc: Ralph Campbell <rcampbell@nvidia.com>
> ---
>   lib/test_hmm.c |    3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> --- linux-next-20200617.orig/lib/test_hmm.c
> +++ linux-next-20200617/lib/test_hmm.c
> @@ -520,8 +520,7 @@ static bool dmirror_allocate_chunk(struc
>   err_free:
>   	kfree(devmem);
>   err_release:
> -	release_mem_region(devmem->pagemap.res.start,
> -			   resource_size(&devmem->pagemap.res));
> +	release_mem_region(res->start, resource_size(res));
>   err:
>   	mutex_unlock(&mdevice->devmem_lock);
>   	return false;
> 

Thanks for fixing this!
Reviewed-by: Ralph Campbell <rcampbell@nvidia.com>


      reply	other threads:[~2020-06-18 16:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-18  5:31 Randy Dunlap
2020-06-18 16:21 ` Ralph Campbell [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fae8934b-7300-27ff-e18e-6db413b9ea53@nvidia.com \
    --to=rcampbell@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=jglisse@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rdunlap@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox