Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp166618imm; Tue, 12 Jun 2018 21:06:19 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKkYL4wmqsRCxOeNQdYqimnsnObaHrzWiNkbWYsNTADHQ7Cry9Sg8b317+JZT/nW8bJ161j X-Received: by 2002:aa7:8589:: with SMTP id w9-v6mr3207948pfn.119.1528862779360; Tue, 12 Jun 2018 21:06:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528862779; cv=none; d=google.com; s=arc-20160816; b=CM/nRtLCQcmwLoQSTqw0JRsPizUFjarrlb08GJFCzOCjjJ85HyO53s/vA3LRPvyAsd IugZ0wF6UQ3exnaMARYQRc0PLUJvzU8u/1Cibm7cEVXZN1V4bO8R6j2LyB+ZXAnq3qaT cu8+SAF8W0VRbZNzaR0NVF0o3qZpN3Ch/XhVnx3pN17J14ZGY16cVieDSoO4fqx9U2qZ WBgZVaOARHMFy5uORgZOWlFCn9ITcXpGXYEhgFtF99S1gH+KVgfuQLYC4/g8M7Dx7wDC 0fyKa14tChYZBc8/E5kQqbFJ7y8ZXAmLyL69FYwZU02iCRA6isjgir4oFUcaTIyuYvjK yhIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=LrGrof3ktBcV47sjmbtHBEVVh1yN0ezXIi7oD3SxfOs=; b=1EfOd+5USqIw+wOILUSOoy3WeseFxlvKpg3amsBFZI9sx0ahD/di7m/DJl+T6Zgj4D 5t7c253pr1s+Tl7lJvAnO0C/R2zYIQyze2SMBOlqUidA42FvCyBQWqyk/kueVatJUQ2U 1amswGuSuIAqPgEs43AVrKBnk/UONWIfYYZGVcKRt8fNjVRk1aumoDahViKPdxxgkhsA Y+x3j+onwIE0bqOLU2+nz5nBw1usG2eC7xXmI8+RARFitY9m27ye53IhKQvtPMA0tRke RIeE1TldbaMqP4Fo+h2rewklESxAuk8e/JY/N8U138Ok5BOVjT8+dW5Eh9LRPiTHnq5x E4jQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si1760347plw.519.2018.06.12.21.06.05; Tue, 12 Jun 2018 21:06:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754431AbeFMEFi (ORCPT + 99 others); Wed, 13 Jun 2018 00:05:38 -0400 Received: from mout.gmx.net ([212.227.15.18]:41707 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751136AbeFMEFh (ORCPT ); Wed, 13 Jun 2018 00:05:37 -0400 Received: from juanniu018037.ss.mogujie.org ([122.225.81.134]) by mail.gmx.com (mrgmx001 [212.227.17.184]) with ESMTPSA (Nemesis) id 0McmFl-1fktYr3J0D-00Hsef; Wed, 13 Jun 2018 06:05:33 +0200 From: Chengguang Xu To: ooo@electrozaur.com Cc: linux-kernel@vger.kernel.org, Chengguang Xu Subject: [PATCH 1/2] fs/exofs: fix potential memory leak in mount option parsing Date: Wed, 13 Jun 2018 12:05:13 +0800 Message-Id: <1528862714-78150-1-git-send-email-cgxu519@gmx.com> X-Mailer: git-send-email 1.8.3.1 X-Provags-ID: V03:K1:zZfIPePDmA/fUt0e1SUj4qykbbJwJ3MZxbQgq7Vua1q3b73Ckd4 5udHNWdqqizXZXH9rErFNE9ycpVZJZTDl4E+oRyGwhiy/ovMzGbL3mi3ez19TFRX4YrcRPM 2WnoC2ewsRrXDOEGwux2LRSQLQh61zOaEk/dH4YSBaEMHHsy/B2mUCHS2tGQf/jpiJOdGA7 Wx0ZXqVnNKDMZXyvzE2jw== X-UI-Out-Filterresults: notjunk:1;V01:K0:BtyDXVW06GA=:XxGVYHUjKdwRU7wHRJB/oL /UHRxFBql6UOUnwkhcAdG4bAGr635pUen3xqCNBzCyg3BCrNSVS8GTtb9gtzZbqjeW+mBam4q bgdk4BJ2uH2b1P10Ft5CK2XH3EnSjv3ao7iNGkSYHh/fFs07CmOVtTTflWPvA4HX6x+U8vnGQ +QT/L/WK4H5pkw+f1x7MQoAgxabps9drLGV5yiVRW2ZB4wAsrOycnsVYFsCjSwAOqoihse4Bh UwWinOAW5BR+vfW12WjQM3BMDlN9LUOFTXin4MS752KSMWNxekaNvJ/71yIFGJUvUkLFM9DMg /g9oCCDCf2L6zybS36cWPxvNj8IETGdiNSV4dWzc+99zdxzn6l2yUyfgGicmWEN/s9iokj3cn v6REWwwjVbWn3/j4oMXmLkiSTlk9NTA6dHJ6QSxw+MvSv8/YDGaLnlSb0SKPNxMyHCXxBig4h Yyx3IlITHNSREu4E2PKM/KLiH26nv0tAU1mMn4VJaL1aoEZzwj/F7zRl39syd6DfiQggdrb48 BS/NqvtUIbGX0+OHsghNDF6pwiQ2iieTuI1n10RJOfIZNdR0tlOsFAz+diX0MhO8czcEWVd3J 7f2lvXneIvcy2hJd+tL4IxEkFY0IZBjxHB4LjfbUQr4dqcL/vE6BWGs5J7DdY3Y9rXFhFc5yr 9i+SjdgBzmV0ngKiaoEfgnC7sWdDe8olM9EFuiRLcEeIoQKvCKwK6N3fTtV+d8eDQgfZlXFSq R2qL/6Z6ErN6SINvK91VduD8NdEbluI2Wfc/oevh0bhqzb21NILS3MAEQV4= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are some cases can cause memory leak when parsing option 'osdname'. Signed-off-by: Chengguang Xu --- fs/exofs/super.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/exofs/super.c b/fs/exofs/super.c index 719a315..f3e17a9 100644 --- a/fs/exofs/super.c +++ b/fs/exofs/super.c @@ -101,6 +101,7 @@ static int parse_options(char *options, struct exofs_mountopt *opts) token = match_token(p, tokens, args); switch (token) { case Opt_name: + kfree(opts->dev_name); opts->dev_name = match_strdup(&args[0]); if (unlikely(!opts->dev_name)) { EXOFS_ERR("Error allocating dev_name"); @@ -867,8 +868,10 @@ static struct dentry *exofs_mount(struct file_system_type *type, int ret; ret = parse_options(data, &opts); - if (ret) + if (ret) { + kfree(opts.dev_name); return ERR_PTR(ret); + } if (!opts.dev_name) opts.dev_name = dev_name; -- 1.8.3.1