From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8307DA0527 for ; Mon, 9 Nov 2020 19:42:21 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 794BF6883; Mon, 9 Nov 2020 19:42:20 +0100 (CET) Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) by dpdk.org (Postfix) with ESMTP id 566106883 for ; Mon, 9 Nov 2020 19:42:16 +0100 (CET) Received: by mail-wm1-f46.google.com with SMTP id v5so462980wmh.1 for ; Mon, 09 Nov 2020 10:42:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vF1Iw3nFPeb3GxlqGQufUTf/DTYU45CSMrGRF/1IsQU=; b=PuR7BKa6mCS60fQ8Rc1oiPpfqEZjAD8pXkeBhCd3b8qEjtAOd7/SKMwygQP2DN7Jm6 McZ6Mpq59N3RID0JfFClGr67vezAwdgleh+eAX/vTFhUfA3U1ed4wJrYJRKkVHDpUwmG R3sZq1EUnv3xxigdG+sDyeNPkhVAnrkT+kRYvkJeuHSS02LiKw1rmTaJGW2tUwJnzx0W EKQTlIzmmPNvybHs1Wpp9pj1ckJDCV8cpbpmgknCwJzphXDZzzPHo6TiYVcfuWrxdm0o YCYI3xcEaI2tPcD3YKxHiXrueMMu1FC6orwbAPe4ucvFl9Ux5GRdjRglHbSLnYIyqSNp 5VfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vF1Iw3nFPeb3GxlqGQufUTf/DTYU45CSMrGRF/1IsQU=; b=pmyYKNc5ZcIzfZCMBI4YDmLE367sOOnVXUbCwWNdf8lh4LLZ1Ggir37NMKFuCJxxPM PAlL1gAbSGD1IBihTzxATK9Ez4QKpPliYBMIp9n+RMRAKP7JUmc0YS9qZRCrseVFL8Fy 6n/uQQvS0lfzE1zN9WxggaPt5GcbI1beSIIRd0PGvrrYyqE89VvwBEah+k44pLWkw77r u/6E05omjvHC2mVBpDkf60d2f4SWvsIupFvY4zvFUv9r5SbCvrxYlyWM3vv2EfSYSxfd kD13j+YIakEyP1BfSfnpXwn7Zc9qQGalP0Ma5ouyuFhXiOzLsD2SQUEDu8HPbCtohhWJ dXWw== X-Gm-Message-State: AOAM531CrG4ncAwaQpLdyWqzoAUciX/4hiWVFsXvBdu1ZNHQMSr1nDao H9coSaWAEpwsMqDgbCpNVWU= X-Google-Smtp-Source: ABdhPJxrIeCYWqceWdXf//GuEDmWaxncRNxBiLOO6qDVUl0F48CFIzlXeb57Py550WndtkTdXFhGCA== X-Received: by 2002:a1c:4e0e:: with SMTP id g14mr542382wmh.9.1604947336113; Mon, 09 Nov 2020 10:42:16 -0800 (PST) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id l24sm353672wmi.7.2020.11.09.10.42.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 10:42:15 -0800 (PST) From: luca.boccassi@gmail.com To: Yunjian Wang Cc: Nicolas Chautru , dpdk stable Date: Mon, 9 Nov 2020 18:40:05 +0000 Message-Id: <20201109184111.3463090-17-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201109184111.3463090-1-luca.boccassi@gmail.com> References: <20201028104606.3504127-207-luca.boccassi@gmail.com> <20201109184111.3463090-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'baseband/turbo_sw: fix memory leak in error path' has been queued to stable release 19.11.6 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/11/20. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/a973d06b4f47609fb3ef4fc483bc483a57ee1c61 Thanks. Luca Boccassi --- >From a973d06b4f47609fb3ef4fc483bc483a57ee1c61 Mon Sep 17 00:00:00 2001 From: Yunjian Wang Date: Thu, 15 Oct 2020 21:45:45 +0800 Subject: [PATCH] baseband/turbo_sw: fix memory leak in error path [ upstream commit 240fb56cdb8a4d48359f83b2cb856410016b9207 ] In q_setup() allocated memory for the queue data, we should free it when error happens, otherwise it will lead to memory leak. Fixes: b8cfe2c9aed2 ("bb/turbo_sw: add software turbo driver") Signed-off-by: Yunjian Wang Reviewed-by: Nicolas Chautru --- .../baseband/turbo_sw/bbdev_turbo_software.c | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/drivers/baseband/turbo_sw/bbdev_turbo_software.c b/drivers/baseband/turbo_sw/bbdev_turbo_software.c index e6d9501240..18c4649917 100644 --- a/drivers/baseband/turbo_sw/bbdev_turbo_software.c +++ b/drivers/baseband/turbo_sw/bbdev_turbo_software.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -303,7 +304,8 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, rte_bbdev_log(ERR, "Creating queue name for device %u queue %u failed", dev->data->dev_id, q_id); - return -ENAMETOOLONG; + ret = -ENAMETOOLONG; + goto free_q; } q->enc_out = rte_zmalloc_socket(name, ((RTE_BBDEV_TURBO_MAX_TB_SIZE >> 3) + 3) * @@ -312,6 +314,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, if (q->enc_out == NULL) { rte_bbdev_log(ERR, "Failed to allocate queue memory for %s", name); + ret = -ENOMEM; goto free_q; } @@ -323,7 +326,8 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, rte_bbdev_log(ERR, "Creating queue name for device %u queue %u failed", dev->data->dev_id, q_id); - return -ENAMETOOLONG; + ret = -ENAMETOOLONG; + goto free_q; } q->enc_in = rte_zmalloc_socket(name, (RTE_BBDEV_LDPC_MAX_CB_SIZE >> 3) * sizeof(*q->enc_in), @@ -331,6 +335,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, if (q->enc_in == NULL) { rte_bbdev_log(ERR, "Failed to allocate queue memory for %s", name); + ret = -ENOMEM; goto free_q; } @@ -341,7 +346,8 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, rte_bbdev_log(ERR, "Creating queue name for device %u queue %u failed", dev->data->dev_id, q_id); - return -ENAMETOOLONG; + ret = -ENAMETOOLONG; + goto free_q; } q->ag = rte_zmalloc_socket(name, RTE_BBDEV_TURBO_MAX_CB_SIZE * 10 * sizeof(*q->ag), @@ -349,6 +355,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, if (q->ag == NULL) { rte_bbdev_log(ERR, "Failed to allocate queue memory for %s", name); + ret = -ENOMEM; goto free_q; } @@ -359,7 +366,8 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, rte_bbdev_log(ERR, "Creating queue name for device %u queue %u failed", dev->data->dev_id, q_id); - return -ENAMETOOLONG; + ret = -ENAMETOOLONG; + goto free_q; } q->code_block = rte_zmalloc_socket(name, RTE_BBDEV_TURBO_MAX_CB_SIZE * sizeof(*q->code_block), @@ -367,6 +375,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, if (q->code_block == NULL) { rte_bbdev_log(ERR, "Failed to allocate queue memory for %s", name); + ret = -ENOMEM; goto free_q; } @@ -378,7 +387,8 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, rte_bbdev_log(ERR, "Creating queue name for device %u queue %u failed", dev->data->dev_id, q_id); - return -ENAMETOOLONG; + ret = -ENAMETOOLONG; + goto free_q; } q->deint_input = rte_zmalloc_socket(name, DEINT_INPUT_BUF_SIZE * sizeof(*q->deint_input), @@ -386,6 +396,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, if (q->deint_input == NULL) { rte_bbdev_log(ERR, "Failed to allocate queue memory for %s", name); + ret = -ENOMEM; goto free_q; } @@ -397,7 +408,8 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, rte_bbdev_log(ERR, "Creating queue name for device %u queue %u failed", dev->data->dev_id, q_id); - return -ENAMETOOLONG; + ret = -ENAMETOOLONG; + goto free_q; } q->deint_output = rte_zmalloc_socket(NULL, DEINT_OUTPUT_BUF_SIZE * sizeof(*q->deint_output), @@ -405,6 +417,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, if (q->deint_output == NULL) { rte_bbdev_log(ERR, "Failed to allocate queue memory for %s", name); + ret = -ENOMEM; goto free_q; } @@ -416,7 +429,8 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, rte_bbdev_log(ERR, "Creating queue name for device %u queue %u failed", dev->data->dev_id, q_id); - return -ENAMETOOLONG; + ret = -ENAMETOOLONG; + goto free_q; } q->adapter_output = rte_zmalloc_socket(NULL, ADAPTER_OUTPUT_BUF_SIZE * sizeof(*q->adapter_output), @@ -424,6 +438,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, if (q->adapter_output == NULL) { rte_bbdev_log(ERR, "Failed to allocate queue memory for %s", name); + ret = -ENOMEM; goto free_q; } @@ -434,12 +449,14 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, rte_bbdev_log(ERR, "Creating queue name for device %u queue %u failed", dev->data->dev_id, q_id); - return -ENAMETOOLONG; + ret = -ENAMETOOLONG; + goto free_q; } q->processed_pkts = rte_ring_create(name, queue_conf->queue_size, queue_conf->socket, RING_F_SP_ENQ | RING_F_SC_DEQ); if (q->processed_pkts == NULL) { rte_bbdev_log(ERR, "Failed to create ring for %s", name); + ret = -rte_errno; goto free_q; } @@ -459,7 +476,7 @@ free_q: rte_free(q->deint_output); rte_free(q->adapter_output); rte_free(q); - return -EFAULT; + return ret; } static const struct rte_bbdev_ops pmd_ops = { -- 2.27.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-11-09 18:40:11.896932363 +0000 +++ 0017-baseband-turbo_sw-fix-memory-leak-in-error-path.patch 2020-11-09 18:40:11.091310660 +0000 @@ -1 +1 @@ -From 240fb56cdb8a4d48359f83b2cb856410016b9207 Mon Sep 17 00:00:00 2001 +From a973d06b4f47609fb3ef4fc483bc483a57ee1c61 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 240fb56cdb8a4d48359f83b2cb856410016b9207 ] + @@ -10 +11,0 @@ -Cc: stable@dpdk.org @@ -19 +20 @@ -index a36099e91d..aa7f122382 100644 +index e6d9501240..18c4649917 100644 @@ -30 +31 @@ -@@ -302,7 +303,8 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, +@@ -303,7 +304,8 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, @@ -40 +41 @@ -@@ -311,6 +313,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, +@@ -312,6 +314,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, @@ -48 +49 @@ -@@ -322,7 +325,8 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, +@@ -323,7 +326,8 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, @@ -58 +59 @@ -@@ -330,6 +334,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, +@@ -331,6 +335,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, @@ -66 +67 @@ -@@ -340,7 +345,8 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, +@@ -341,7 +346,8 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, @@ -76 +77 @@ -@@ -348,6 +354,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, +@@ -349,6 +355,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, @@ -84 +85 @@ -@@ -358,7 +365,8 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, +@@ -359,7 +366,8 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, @@ -94 +95 @@ -@@ -366,6 +374,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, +@@ -367,6 +375,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, @@ -102 +103 @@ -@@ -377,7 +386,8 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, +@@ -378,7 +387,8 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, @@ -112 +113 @@ -@@ -385,6 +395,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, +@@ -386,6 +396,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, @@ -120 +121 @@ -@@ -396,7 +407,8 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, +@@ -397,7 +408,8 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, @@ -130 +131 @@ -@@ -404,6 +416,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, +@@ -405,6 +417,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, @@ -138 +139 @@ -@@ -415,7 +428,8 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, +@@ -416,7 +429,8 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, @@ -148 +149 @@ -@@ -423,6 +437,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, +@@ -424,6 +438,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, @@ -156 +157 @@ -@@ -433,12 +448,14 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, +@@ -434,12 +449,14 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, @@ -172 +173 @@ -@@ -458,7 +475,7 @@ free_q: +@@ -459,7 +476,7 @@ free_q: