Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2330065imm; Fri, 7 Sep 2018 14:47:19 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdaosp+DCMmb3+OuXpa7YQbEjsdLcxsBgVLHU4YlVDXgbk/f73wMzbSB1X4edEiSvUdlIhmU X-Received: by 2002:a63:d946:: with SMTP id e6-v6mr10458214pgj.24.1536356839742; Fri, 07 Sep 2018 14:47:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536356839; cv=none; d=google.com; s=arc-20160816; b=BNtI22Y/84FqUtfAc9LmVZBinA84Oxurfx/tu7mrEhL3JomW3gGDlTw6hqjHHtQa18 UrxJ+J0SKQacOZeSVb5e9HnaPcqIgPpZZr0foipZskG7RlDEQOqauGigDdbhyfc+0Ew0 HrMsQksHOiXcq+HCAnPOcH4kaRVAV+B20fel/poLtg3k5G6pnj0OO0/HJimBvCstfhIz zQeuL1L87viRDd4z1MqXHqA62vxznP+JhfDrPXBrfMlrwg3iCbVDVdkqgXzKcIwjHVVg 6oUHb2b8PgP+HzUkfbCxnDES0okUujoObn60jvPB2fcN7rsPCfqiwvBrPZYnDdnC/ezc X3Xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from; bh=dMV/pOL+EDxF1px4ykyJcl3IjkNuK1lES2aQPH3lZkA=; b=nhsnBQw6qfbSOITsfnL4L20AUdkd7JS8Qn7nO/THg5645yKoiBE44YeVSnaMV9QLp4 VO4SIf/BlnsT6c6l6CDVLPD7/39bYEOIzkVe55hCc2u4EwylML3+RQUokKOAUAqWQJVr AEsiqpGfyrZC97+yv46CWiS1gYxfGcvICji27sjsyDubScfDUcFFsfDgY5TcwTZ+b6vS HIIH8D7qLo38XiVVbheOX7nfbBdXgHbmmsFm4ip5vs7ac8ARIAU4ws+ue1xNOHCI/mFr qdhV81TT5FH9WtuPo6PowjslXmjgUHoObA2sEBLE4gKJRA1I6/Q9R+YKCKxeoSp7e4nS updw== 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 d130-v6si9736378pga.657.2018.09.07.14.47.04; Fri, 07 Sep 2018 14:47: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 S1730949AbeIHC1R (ORCPT + 99 others); Fri, 7 Sep 2018 22:27:17 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:57720 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727983AbeIHC1Q (ORCPT ); Fri, 7 Sep 2018 22:27:16 -0400 Received: from localhost (ip-213-127-74-90.ip.prioritytelecom.net [213.127.74.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id BE8E21028; Fri, 7 Sep 2018 21:44:20 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Richard Weinberger Subject: [PATCH 3.18 22/29] ubifs: Fix memory leak in lprobs self-check Date: Fri, 7 Sep 2018 23:10:43 +0200 Message-Id: <20180907210911.026574141@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180907210909.523240901@linuxfoundation.org> References: <20180907210909.523240901@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Richard Weinberger commit eef19816ada3abd56d9f20c88794cc2fea83ebb2 upstream. Allocate the buffer after we return early. Otherwise memory is being leaked. Cc: Fixes: 1e51764a3c2a ("UBIFS: add new flash file system") Signed-off-by: Richard Weinberger Signed-off-by: Greg Kroah-Hartman --- fs/ubifs/lprops.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/fs/ubifs/lprops.c +++ b/fs/ubifs/lprops.c @@ -1091,10 +1091,6 @@ static int scan_check_cb(struct ubifs_in } } - buf = __vmalloc(c->leb_size, GFP_NOFS, PAGE_KERNEL); - if (!buf) - return -ENOMEM; - /* * After an unclean unmount, empty and freeable LEBs * may contain garbage - do not scan them. @@ -1113,6 +1109,10 @@ static int scan_check_cb(struct ubifs_in return LPT_SCAN_CONTINUE; } + buf = __vmalloc(c->leb_size, GFP_NOFS, PAGE_KERNEL); + if (!buf) + return -ENOMEM; + sleb = ubifs_scan(c, lnum, 0, buf, 0); if (IS_ERR(sleb)) { ret = PTR_ERR(sleb);