From patchwork Sat May 8 11:09:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wangyunjian X-Patchwork-Id: 432946 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=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham 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 04B5FC433B4 for ; Sat, 8 May 2021 11:09:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CE5F761424 for ; Sat, 8 May 2021 11:09:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230416AbhEHLKn (ORCPT ); Sat, 8 May 2021 07:10:43 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:17602 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230326AbhEHLKn (ORCPT ); Sat, 8 May 2021 07:10:43 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FckzW0QjBz16PYg; Sat, 8 May 2021 19:07:03 +0800 (CST) Received: from localhost (10.174.243.60) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.498.0; Sat, 8 May 2021 19:09:29 +0800 From: wangyunjian To: , CC: , , , , Yunjian Wang Subject: [PATCH net] iwlwifi: pnvm: fix resource leaks in iwl_pnvm_get_from_fs Date: Sat, 8 May 2021 19:09:25 +0800 Message-ID: <1620472165-7960-1-git-send-email-wangyunjian@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 MIME-Version: 1.0 X-Originating-IP: [10.174.243.60] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Yunjian Wang Currently the error return path does not release the "pnvm" when kmemdup fails and also the "pnvm" is not relased in the normal path. These lead to a resource leak. Fix these by releasing "pnvm" before return. Addresses-Coverity: ("Resource leak") Fixes: cdda18fbbefa ("iwlwifi: pnvm: move file loading code to a separate function") Signed-off-by: Yunjian Wang --- drivers/net/wireless/intel/iwlwifi/fw/pnvm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c b/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c index 40f2109a097f..d4ac83848926 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c +++ b/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c @@ -322,10 +322,13 @@ static int iwl_pnvm_get_from_fs(struct iwl_trans *trans, u8 **data, size_t *len) } *data = kmemdup(pnvm->data, pnvm->size, GFP_KERNEL); - if (!*data) + if (!*data) { + release_firmware(pnvm); return -ENOMEM; + } *len = pnvm->size; + release_firmware(pnvm); return 0; }