All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Kyle Spiers <ksspiers@google.com>
Cc: jack@suse.cz, arnd@arndb.de, dhowells@redhat.com,
	gregkh@linuxfoundation.org, keescook@chromium.org,
	joe@perches.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] isofs compress: Remove VLA usage
Date: Wed, 11 Apr 2018 01:33:31 +0100	[thread overview]
Message-ID: <20180411003331.GM30522@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20180410234532.185426-1-ksspiers@google.com>

On Tue, Apr 10, 2018 at 04:45:32PM -0700, Kyle Spiers wrote:
> As part of the effort to remove VLAs from the kernel[1], this changes
> the allocation of the bhs and pages arrays from being on the stack to being
> kcalloc()ed. This also allows for the removal of the explicit zeroing
> of bhs.
> 
> https://lkml.org/lkml/2018/3/7/621

Do you even bother reading the feedback given to such patches?  I'm just
curious,

> @@ -80,7 +81,9 @@ static loff_t zisofs_uncompress_block(struct inode *inode, loff_t block_start,
>  
>  	/* Because zlib is not thread-safe, do all the I/O at the top. */
>  	blocknum = block_start >> bufshift;
> -	memset(bhs, 0, (needblocks + 1) * sizeof(struct buffer_head *));
> +	bhs = kcalloc(needblocks + 1, sizeof(*bhs), GFP_KERNEL);
> +	if (!bhs)
> +		return -ENOMEM;

... because I distinctly remember comments along the lines of "check what
other failure exits look like in there, such as
                *errp = -EIO;
                return 0;
nearby".

> @@ -330,6 +334,10 @@ static int zisofs_readpage(struct file *file, struct page *page)
>  		full_page = 0;
>  		pcount = 1;
>  	}
> +	pages = kcalloc(max_t(unsigned int, zisofs_pages_per_cblock, 1),
> +					sizeof(*pages), GFP_KERNEL);
> +	if (!pages)
> +		return -ENOMEM;
>  	pages[full_page] = page;

What, in your opinion, is going to unlock that page after that failure exit?

  reply	other threads:[~2018-04-11  0:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-10 23:45 [PATCH v3] isofs compress: Remove VLA usage Kyle Spiers
2018-04-11  0:33 ` Al Viro [this message]
2018-04-11  0:51   ` Kees Cook
2018-04-11  6:15     ` Joe Perches
2018-04-11  6:39       ` Al Viro
2018-04-11 14:53         ` Joe Perches

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=20180411003331.GM30522@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=arnd@arndb.de \
    --cc=dhowells@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jack@suse.cz \
    --cc=joe@perches.com \
    --cc=keescook@chromium.org \
    --cc=ksspiers@google.com \
    --cc=linux-kernel@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.