From patchwork Tue Jan 25 15:29:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 1584133 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=FVVs8gpw; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JjrPt0x3yz9t6g for ; Wed, 26 Jan 2022 02:29:52 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1nCNlR-0000fF-Is; Tue, 25 Jan 2022 15:29:45 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1nCNlP-0000em-Dk for kernel-team@lists.ubuntu.com; Tue, 25 Jan 2022 15:29:43 +0000 Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 7BE383F1B4 for ; Tue, 25 Jan 2022 15:29:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1643124582; bh=CgMQ7AjmI+aC0A+QcY6Y3D1dP3KtpUV9CtFv1C3qapw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=FVVs8gpwClEXBPsbhfsX5g9Rmq+nL6ju7s3bG8JOoZKVOu0xvDCZh4Wv8PvOVpost l0YTfuKZFlqUvMPyuYLBp+6yYwk4P8NhRmvt4YzNtgPP9o+gIPTWCBwDUNA8iV64s/ UT8lvMS2rIO8iICVCbno4qvMMdgUKawB+ITSp4c4E/dJtmj68HrpKc3UXmZjI0sd9N ljqHKkrAzlmZUTW1Ze+aLlt+5ys1IfLFxYRpBsTiKS5kjKoucTR6yGi2Q631cswZYW O6COG8KtIQVicRJh55vLIJ0B+UIFxx14U4haaWAAPitq0bAxw7nxT7/r8jvm9tzyDs XFbavCk6qUhEQ== Received: by mail-pl1-f198.google.com with SMTP id cp2-20020a170902e78200b0014a9f3e3c1fso5249465plb.5 for ; Tue, 25 Jan 2022 07:29:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CgMQ7AjmI+aC0A+QcY6Y3D1dP3KtpUV9CtFv1C3qapw=; b=GXkDAea3cITMZYfaaPSogBzeFF80SO4KrqQ1vOuVywtBMN+5rg8mDIYX3r02K7TbQ+ MHJ4vhaKg4A3RkJ6e2ZuiFFGQPMuTB1vevc9qpt19VEcnkukGE6Rj56mk/RFywcjznl2 Tm+LYHS6cq146PeMA551LuZr8u6uvxRvSuMRi16AG9+A9Ismd6Tdlil2StaKttr4EyAs CgktTZpUIiM9A9+zJNzUFabw1Rw5rUMLBQo33e8XPYU+nLEwCk2spzbkJtRgVd31hjey 0IlKjcqjwi1VxhxFVT0qmqqH3plmTj57qeeWuv5155rbrBr9qMoAkVnhKpfpouGQ2Hc/ hz9w== X-Gm-Message-State: AOAM532uTNAd78d4KJKriOiVXGrLuK5+l1mqikJ5IhM0FjhLp8c2oz/9 irWzMPYWLPwZxtuhAyZXNU0/oaMdER2zDkYTNmtLysbMB9/9LZ7dnprg6FBX6Qz4oxK1j4WMt0u jZ6g+cazrOZnxIMTMelewHe6Hgq0aLt4j5HkWWOW9qA== X-Received: by 2002:a65:464e:: with SMTP id k14mr15542346pgr.225.1643124580694; Tue, 25 Jan 2022 07:29:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJyI19qzN9cMKixI3Pm6Oeou9AaFBNK9yGOg+rPBqfDk4OTwczFPx7877PH0oa2rUvCLidyAAg== X-Received: by 2002:a65:464e:: with SMTP id k14mr15542336pgr.225.1643124580384; Tue, 25 Jan 2022 07:29:40 -0800 (PST) Received: from localhost.localdomain ([69.163.84.166]) by smtp.gmail.com with ESMTPSA id s6sm15321071pgk.44.2022.01.25.07.29.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 07:29:39 -0800 (PST) From: Tim Gardner To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/2] net: mana: Fix memory leak in mana_hwc_create_wq Date: Tue, 25 Jan 2022 08:29:21 -0700 Message-Id: <20220125152921.16937-3-tim.gardner@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220125152921.16937-1-tim.gardner@canonical.com> References: <20220125152921.16937-1-tim.gardner@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: José Expósito BugLink: https://bugs.launchpad.net/bugs/1959012 If allocating the DMA buffer fails, mana_hwc_destroy_wq was called without previously storing the pointer to the queue. In order to avoid leaking the pointer to the queue, store it as soon as it is allocated. Addresses-Coverity-ID: 1484720 ("Resource leak") Signed-off-by: José Expósito Reviewed-by: Dexuan Cui Link: https://lore.kernel.org/r/20211208223723.18520-1-jose.exposito89@gmail.com Signed-off-by: Jakub Kicinski (cherry picked from commit 9acfc57fa2b8944ed079cedbf846823ea32b8a31) Signed-off-by: Tim Gardner --- drivers/net/ethernet/microsoft/mana/hw_channel.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/microsoft/mana/hw_channel.c b/drivers/net/ethernet/microsoft/mana/hw_channel.c index 34b971ff8ef8..078d6a5a0768 100644 --- a/drivers/net/ethernet/microsoft/mana/hw_channel.c +++ b/drivers/net/ethernet/microsoft/mana/hw_channel.c @@ -480,16 +480,16 @@ static int mana_hwc_create_wq(struct hw_channel_context *hwc, if (err) goto out; - err = mana_hwc_alloc_dma_buf(hwc, q_depth, max_msg_size, - &hwc_wq->msg_buf); - if (err) - goto out; - hwc_wq->hwc = hwc; hwc_wq->gdma_wq = queue; hwc_wq->queue_depth = q_depth; hwc_wq->hwc_cq = hwc_cq; + err = mana_hwc_alloc_dma_buf(hwc, q_depth, max_msg_size, + &hwc_wq->msg_buf); + if (err) + goto out; + *hwc_wq_ptr = hwc_wq; return 0; out: