From patchwork Mon Jan 25 18:39:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 372386 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2FF69C433E0 for ; Tue, 26 Jan 2021 21:15:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 02C9A22B3B for ; Tue, 26 Jan 2021 21:15:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728533AbhAZEuu (ORCPT ); Mon, 25 Jan 2021 23:50:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:33932 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730492AbhAYSrC (ORCPT ); Mon, 25 Jan 2021 13:47:02 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 153B622482; Mon, 25 Jan 2021 18:46:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1611600383; bh=pWOdn91w4KjUPAGY7fEWq+uUAnXkiYb6vnjmdJc9Wks=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PHMdg3sdK5rO9e3pWCCfGjwMvC0QNbPMNpXM2ICOo5ufbcR5Y9UQW0xYSPZpTNI7K pM4BHV9mhh8JZT9BgqwowiTCtqmzpOYLMFzcg6Vu1bA99Tup8CsJEHNP1O/o4aitz7 2pVqILgdGyEvb37t6Dwicj717XVjoMAytd+LP+Ps= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pan Bian , Jens Axboe Subject: [PATCH 5.4 73/86] lightnvm: fix memory leak when submit fails Date: Mon, 25 Jan 2021 19:39:55 +0100 Message-Id: <20210125183204.128953823@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210125183201.024962206@linuxfoundation.org> References: <20210125183201.024962206@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Pan Bian commit 97784481757fba7570121a70dd37ca74a29f50a8 upstream. The allocated page is not released if error occurs in nvm_submit_io_sync_raw(). __free_page() is moved ealier to avoid possible memory leak issue. Fixes: aff3fb18f957 ("lightnvm: move bad block and chunk state logic to core") Signed-off-by: Pan Bian Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- drivers/lightnvm/core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -849,11 +849,10 @@ static int nvm_bb_chunk_sense(struct nvm rqd.ppa_addr = generic_to_dev_addr(dev, ppa); ret = nvm_submit_io_sync_raw(dev, &rqd); + __free_page(page); if (ret) return ret; - __free_page(page); - return rqd.error; }