From: Guru Das Srinagesh <gurooodas@gmail.com>
To: Joe Perches <joe@perches.com>
Cc: oleg.drokin@intel.com, andreas.dilger@intel.com,
jsimmons@infradead.org, gregkh@linuxfoundation.org,
john.hammond@intel.com, lustre-devel@lists.lustre.org,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: [lustre-devel] [PATCH] staging: lustre: llite: Fix variable length array warning
Date: Sat, 6 May 2017 13:16:29 -0700 [thread overview]
Message-ID: <20170506201629.GA14929@alpha> (raw)
In-Reply-To: <1493974356.31950.13.camel@perches.com>
On Fri, May 05, 2017 at 01:52:36AM -0700, Joe Perches wrote:
> On Thu, 2017-05-04 at 23:41 -0700, Guru Das Srinagesh wrote:
> > Fix sparse warning "warning: Variable length array is used." by using
> > kmalloc_array to allocate the required amount of memory instead and
> > kfree to deallocate memory after use.
> []
> > diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c
> []
> > @@ -86,7 +86,8 @@ ll_xattr_set_common(const struct xattr_handler *handler,
> > const char *name, const void *value, size_t size,
> > int flags)
> > {
> > - char fullname[strlen(handler->prefix) + strlen(name) + 1];
> > + int fullname_len = strlen(handler->prefix) + strlen(name) + 1;
> > + char *fullname = kmalloc_array(fullname_len, sizeof(char), GFP_KERNEL);
>
> What happens when this allocation fails?
>
Thanks for rightly pointing out the omission of kmalloc_array failure case
handling code. I could check for fullname being NULL and then return -ENOMEM
right there in both functions. I'll go ahead and send a v2 of this patch, with
this modification incorporated, unless there are any more comments or concerns.
Could you please let me know? Thank you.
WARNING: multiple messages have this Message-ID (diff)
From: Guru Das Srinagesh <gurooodas@gmail.com>
To: Joe Perches <joe@perches.com>
Cc: oleg.drokin@intel.com, andreas.dilger@intel.com,
jsimmons@infradead.org, gregkh@linuxfoundation.org,
john.hammond@intel.com, lustre-devel@lists.lustre.org,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: lustre: llite: Fix variable length array warning
Date: Sat, 6 May 2017 13:16:29 -0700 [thread overview]
Message-ID: <20170506201629.GA14929@alpha> (raw)
In-Reply-To: <1493974356.31950.13.camel@perches.com>
On Fri, May 05, 2017 at 01:52:36AM -0700, Joe Perches wrote:
> On Thu, 2017-05-04 at 23:41 -0700, Guru Das Srinagesh wrote:
> > Fix sparse warning "warning: Variable length array is used." by using
> > kmalloc_array to allocate the required amount of memory instead and
> > kfree to deallocate memory after use.
> []
> > diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c
> []
> > @@ -86,7 +86,8 @@ ll_xattr_set_common(const struct xattr_handler *handler,
> > const char *name, const void *value, size_t size,
> > int flags)
> > {
> > - char fullname[strlen(handler->prefix) + strlen(name) + 1];
> > + int fullname_len = strlen(handler->prefix) + strlen(name) + 1;
> > + char *fullname = kmalloc_array(fullname_len, sizeof(char), GFP_KERNEL);
>
> What happens when this allocation fails?
>
Thanks for rightly pointing out the omission of kmalloc_array failure case
handling code. I could check for fullname being NULL and then return -ENOMEM
right there in both functions. I'll go ahead and send a v2 of this patch, with
this modification incorporated, unless there are any more comments or concerns.
Could you please let me know? Thank you.
next prev parent reply other threads:[~2017-05-06 20:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-05 6:41 [lustre-devel] [PATCH] staging: lustre: llite: Fix variable length array warning Guru Das Srinagesh
2017-05-05 6:41 ` Guru Das Srinagesh
2017-05-05 8:52 ` [lustre-devel] " Joe Perches
2017-05-05 8:52 ` Joe Perches
2017-05-06 20:16 ` Guru Das Srinagesh [this message]
2017-05-06 20:16 ` Guru Das Srinagesh
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=20170506201629.GA14929@alpha \
--to=gurooodas@gmail.com \
--cc=andreas.dilger@intel.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=joe@perches.com \
--cc=john.hammond@intel.com \
--cc=jsimmons@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lustre-devel@lists.lustre.org \
--cc=oleg.drokin@intel.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 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.