public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Colin King <colin.king@canonical.com>
Cc: Trond Myklebust <trond.myklebust@hammerspace.com>,
	Anna Schumaker <anna.schumaker@netapp.com>,
	linux-nfs@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] NFS: check for allocation failure from mempool_alloc
Date: Mon, 2 Mar 2020 10:30:43 +0300	[thread overview]
Message-ID: <20200302073043.GA4140@kadam> (raw)
In-Reply-To: <20200226234320.7722-1-colin.king@canonical.com>

On Wed, Feb 26, 2020 at 11:43:20PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> It is possible for mempool_alloc to return null when using
> the GFP_KERNEL flag, so return NULL and avoid a null pointer
> dereference on the following memset of the null pointer.
> 
> Addresses-Coverity: ("Dereference null return")
> Fixes: 2b17d725f9be ("NFS: Clean up writeback code")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  fs/nfs/write.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fs/nfs/write.c b/fs/nfs/write.c
> index c478b772cc49..7ca036660dd1 100644
> --- a/fs/nfs/write.c
> +++ b/fs/nfs/write.c
> @@ -106,6 +106,9 @@ static struct nfs_pgio_header *nfs_writehdr_alloc(void)
>  {
>  	struct nfs_pgio_header *p = mempool_alloc(nfs_wdata_mempool, GFP_KERNEL);
>  
> +	if (!p)

The fixes tag was wrong.  When I searched for the correct fixes tag,
it turned out this was intentional.  See commit 237f8306c302
("NFS: don't expect errors from mempool_alloc().") and commit 518662e0fcb9
("NFS: fix usage of mempools.").

    When passed GFP flags that allow sleeping (such as
    GFP_NOIO), mempool_alloc() will never return NULL, it will
    wait until memory is available.

regards,
dan carpenter


      parent reply	other threads:[~2020-03-02  7:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-26 23:43 [PATCH] NFS: check for allocation failure from mempool_alloc Colin King
2020-02-26 23:48 ` Trond Myklebust
2020-02-26 23:56   ` Colin Ian King
2020-03-02  7:30 ` Dan Carpenter [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=20200302073043.GA4140@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=anna.schumaker@netapp.com \
    --cc=colin.king@canonical.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trond.myklebust@hammerspace.com \
    /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