From patchwork Fri May 26 16:19:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jackie Liu X-Patchwork-Id: 687176 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE6EEC77B73 for ; Fri, 26 May 2023 16:29:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230058AbjEZQ3Q (ORCPT ); Fri, 26 May 2023 12:29:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229629AbjEZQ3P (ORCPT ); Fri, 26 May 2023 12:29:15 -0400 X-Greylist: delayed 561 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 26 May 2023 09:29:13 PDT Received: from out-33.mta1.migadu.com (out-33.mta1.migadu.com [IPv6:2001:41d0:203:375::21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC152BC for ; Fri, 26 May 2023 09:29:13 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1685117990; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=qYU4uF9VbfEtej7g/oa6dO+x31qhOWdcbVmmgCv4IHE=; b=xVmBCDNwqiJXtXJKLxZuGvIgPF7dg+/uDWkgwmuafOjXsIw5oJ9eJQVwuk6h+C65Yj3rSj wbi76bzBU2k9c9mv7CdSMnp+BsVFhqcO4VgOO1FjQmsJmmA0aIeHgfpbyp3O1kFOSe93TA zZBIkkMhd1i9hEOi0Mwl5u3p2zL3g4M= From: Jackie Liu To: njavali@marvell.com Cc: GR-QLogic-Storage-Upstream@marvell.com, linux-scsi@vger.kernel.org Subject: [PATCH] scsi: qla2xxx: Fix memleak on memory alloc failed Date: Sat, 27 May 2023 00:19:36 +0800 Message-Id: <20230526161936.1433332-1-liu.yun@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Jackie Liu Returning directly without free memory can lead to memory leaks, which can be avoided by goto 'fail_dma_pool'. Fixes: 06634d5b6e92 ("scsi: qla2xxx: Return -ENOMEM if kzalloc() fails") Reported-by: k2ci Signed-off-by: Jackie Liu --- drivers/scsi/qla2xxx/qla_os.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 2fa695bf38b7..da7698c8293b 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -4245,7 +4245,7 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len, ql_dbg_pci(ql_dbg_init, ha->pdev, 0xe0ee, "%s: failed alloc dsd\n", __func__); - return -ENOMEM; + goto fail_dma_pool; } ha->dif_bundle_kallocs++;