From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751613AbbCUROb (ORCPT ); Sat, 21 Mar 2015 13:14:31 -0400 Received: from mail-yk0-f196.google.com ([209.85.160.196]:32810 "EHLO mail-yk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751403AbbCURO2 (ORCPT ); Sat, 21 Mar 2015 13:14:28 -0400 From: Sanidhya Kashyap To: dhowells@redhat.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: taesoo@gatech.edu, changwoo@gatech.edu, sanidhya@gatech.edu, blee@gatech.edu, Sanidhya Kashyap Subject: [PATCH] afs: kstrdup() memory handling Date: Sat, 21 Mar 2015 13:13:59 -0400 Message-Id: <1426958039-20266-1-git-send-email-sanidhya.gatech@gmail.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1426956609-27273-1-git-send-email-sanidhya.gatech@gmail.com> References: <1426956609-27273-1-git-send-email-sanidhya.gatech@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Handling kstrdup() failure in case of memory pressure even for new_opts. Signed-off-by: Sanidhya Kashyap --- 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