From patchwork Sat Mar 21 16:50:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sanidhya Kashyap X-Patchwork-Id: 6064461 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8FFBABF90F for ; Sat, 21 Mar 2015 16:50:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9043720357 for ; Sat, 21 Mar 2015 16:50:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AB7482034E for ; Sat, 21 Mar 2015 16:50:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751580AbbCUQu3 (ORCPT ); Sat, 21 Mar 2015 12:50:29 -0400 Received: from mail-yh0-f68.google.com ([209.85.213.68]:34368 "EHLO mail-yh0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751560AbbCUQu2 (ORCPT ); Sat, 21 Mar 2015 12:50:28 -0400 Received: by yhzz6 with SMTP id z6so3781121yhz.1; Sat, 21 Mar 2015 09:50:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=7UkpoQXyXDS6nvhMCwzp7mQEV/+KSf755bkXYsFdVKA=; b=pxHRSpIFD8oqaz5VqTF4gKYGNFGWt2XMRFjfcgSKvTMBQ+yfNTCrQUTNFa9dLrEuD7 lwTcqw5rHON+C/6KsH3O2kl5atXT98cwK3+8JX/R9UUfBwaGr2NZT/tsSi6uanX8vU2t QlngVdSl6xWg3o+Uu1ZFW2vDsHi5S1rpH0cwGd1rc1lN9zrqPSBnZReYZTldkpFgymnt MByGgbL2KH/80eeM//a7D0dPdqAkfkQSmLbq5SQwJyku8wCXRsEkpBvS5+YxG7agF81I bCL3PS7V7Ni8bLKiz7Nk1ya3cAAdgOiScz/E3mm5fGdIVcld8I3a8t5S6kkglJrqfdY8 Eu0w== X-Received: by 10.170.123.138 with SMTP id p132mr98823417ykb.126.1426956628030; Sat, 21 Mar 2015 09:50:28 -0700 (PDT) Received: from headstrong.gtisc (headstrong.gtisc.gatech.edu. [128.61.240.70]) by mx.google.com with ESMTPSA id t2sm6383579yhp.46.2015.03.21.09.50.27 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 21 Mar 2015 09:50:27 -0700 (PDT) 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 12:50:09 -0400 Message-Id: <1426956609-27273-1-git-send-email-sanidhya.gatech@gmail.com> X-Mailer: git-send-email 2.1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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); }