mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Juerg Haefliger <juerg.haefliger@canonical.com>
To: shaggy@kernel.org, jfs-discussion@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] jfs: Add missing NULL pointer check in __get_metapage
Date: Wed, 25 Oct 2017 09:50:36 +0200	[thread overview]
Message-ID: <1dbf4a54-968f-0ca7-da96-e262c653fecb@canonical.com> (raw)
In-Reply-To: <20171004082441.2405-1-juerg.haefliger@canonical.com>


[-- Attachment #1.1: Type: text/plain, Size: 1452 bytes --]

Is this a patch you might consider?

Thanks
...Juerg


On 10/04/2017 10:24 AM, Juerg Haefliger wrote:
> alloc_metapage can return a NULL pointer so check for that. And also emit
> an error message if that happens.
> 
> Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com>
> ---
>  fs/jfs/jfs_metapage.c | 20 +++++++++++++-------
>  1 file changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
> index 1c4b9ad4d7ab..00f21af66872 100644
> --- a/fs/jfs/jfs_metapage.c
> +++ b/fs/jfs/jfs_metapage.c
> @@ -187,14 +187,18 @@ static inline struct metapage *alloc_metapage(gfp_t gfp_mask)
>  {
>  	struct metapage *mp = mempool_alloc(metapage_mempool, gfp_mask);
>  
> -	if (mp) {
> -		mp->lid = 0;
> -		mp->lsn = 0;
> -		mp->data = NULL;
> -		mp->clsn = 0;
> -		mp->log = NULL;
> -		init_waitqueue_head(&mp->wait);
> +	if (!mp) {
> +		jfs_err("mempool_alloc failed!\n");
> +		return NULL;
>  	}
> +
> +	mp->lid = 0;
> +	mp->lsn = 0;
> +	mp->data = NULL;
> +	mp->clsn = 0;
> +	mp->log = NULL;
> +	init_waitqueue_head(&mp->wait);
> +
>  	return mp;
>  }
>  
> @@ -663,6 +667,8 @@ struct metapage *__get_metapage(struct inode *inode, unsigned long lblock,
>  	} else {
>  		INCREMENT(mpStat.pagealloc);
>  		mp = alloc_metapage(GFP_NOFS);
> +		if (!mp)
> +			goto unlock;
>  		mp->page = page;
>  		mp->sb = inode->i_sb;
>  		mp->flag = 0;
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 845 bytes --]

  reply	other threads:[~2017-10-25  7:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-04  8:24 Juerg Haefliger
2017-10-25  7:50 ` Juerg Haefliger [this message]
2017-10-30 22:13   ` [Jfs-discussion] " Dave Kleikamp
2017-11-02  6:59     ` Juerg Haefliger
2017-11-02 13:15       ` Dave Kleikamp
2017-11-02 13:43         ` Juerg Haefliger
2017-11-02 14:44           ` Dave Kleikamp

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=1dbf4a54-968f-0ca7-da96-e262c653fecb@canonical.com \
    --to=juerg.haefliger@canonical.com \
    --cc=jfs-discussion@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shaggy@kernel.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

all inboxes | Powered by JetHome®