From patchwork Sat Mar 21 17:13:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sanidhya Kashyap X-Patchwork-Id: 6064551 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 869E8BF90F for ; Sat, 21 Mar 2015 17:14:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AD5D920357 for ; Sat, 21 Mar 2015 17:14:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9B4E62034A for ; Sat, 21 Mar 2015 17:14:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751466AbbCURO3 (ORCPT ); Sat, 21 Mar 2015 13:14:29 -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 Received: by ykbq200 with SMTP id q200so3406985ykb.0; Sat, 21 Mar 2015 10:14: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:in-reply-to:references; bh=ag9/LHPLFvTDdlp0/XHpQFnYq/5jEmeDumlRA4y0rIE=; b=xQjC5VOO+C5STY1Rn9GxUYmYaon4tacnADzJgOUIOmq4nchEzFaOQmdds5SW794CZM kGVluEHljquxGJVykL2IMDMXCAIavA5vFBK4upx5x97Cex5/hLxHCS7h+3zNo59REds3 OlU5MdpJywrYSPOROwfhI7Jnz2IHEwPXixcdOx4X2RBt/qVJ+E0dmpPR/B+ereA3pclK SpfLlk1760HFrIt8L468vp2pAbXG3HZSoUtoCuQMQmFk6BeVhHkMItKlJI2Ra1N7By2L p7HzMsM2wAPNK8oaA36cU7geS6L7lwzG/DOvULXm/RES8GGbPc/8yyLQcudXN6OfNiYn otvA== X-Received: by 10.236.1.38 with SMTP id 26mr87890036yhc.163.1426958068003; Sat, 21 Mar 2015 10:14:28 -0700 (PDT) Received: from headstrong.gtisc (headstrong.gtisc.gatech.edu. [128.61.240.70]) by mx.google.com with ESMTPSA id g55sm1018062yhb.37.2015.03.21.10.14.27 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 21 Mar 2015 10:14: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 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-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 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); }