From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeff Epler Subject: Re: [PATCH] afs: kstrdup() memory handling Date: Sat, 21 Mar 2015 16:02:51 -0500 Message-ID: <20150321210245.GB17049@unpythonic.net> References: <1426956609-27273-1-git-send-email-sanidhya.gatech@gmail.com> <1426958039-20266-1-git-send-email-sanidhya.gatech@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: dhowells@redhat.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, taesoo@gatech.edu, changwoo@gatech.edu, sanidhya@gatech.edu, blee@gatech.edu To: Sanidhya Kashyap Return-path: Content-Disposition: inline In-Reply-To: <1426958039-20266-1-git-send-email-sanidhya.gatech@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Sat, Mar 21, 2015 at 01:13:59PM -0400, Sanidhya Kashyap wrote: > Handling kstrdup() failure in case of memory pressure even > for new_opts. > > Signed-off-by: Sanidhya Kashyap Reviewed-by: Jeff Epler > --- > fs/afs/super.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/fs/afs/super.c b/fs/afs/super.c > index c486155..477f38e 100644 > --- a/fs/afs/super.c > +++ b/fs/afs/super.c > @@ -360,10 +360,13 @@ static struct dentry *afs_mount(struct file_system_type *fs_type, > struct key *key; > char *new_opts = kstrdup(options, GFP_KERNEL); > struct afs_super_info *as; > - int ret; > + int ret = -ENOMEM; > > _enter(",,%s,%p", dev_name, options); > > + if (!new_opts) > + goto error_out; > + > memset(¶ms, 0, sizeof(params)); > > ret = -EINVAL; > @@ -441,6 +444,7 @@ error: > afs_put_cell(params.cell); > key_put(params.key); > kfree(new_opts); > +error_out: > _leave(" = %d", ret); > return ERR_PTR(ret); > } > -- > 2.1.0 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ >