patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Yuanhan Liu <yliu@fridaylinux.org>
To: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Cc: Fan Zhang <roy.fan.zhang@intel.com>, dpdk stable <stable@dpdk.org>
Subject: [dpdk-stable] patch 'crypto/scheduler: set null pointer after freeing' has been queued to LTS release 17.11.3
Date: Sun, 20 May 2018 21:02:18 +0800	[thread overview]
Message-ID: <20180520130246.16287-2-yliu@fridaylinux.org> (raw)
In-Reply-To: <20180520130246.16287-1-yliu@fridaylinux.org>

Hi,

FYI, your patch has been queued to LTS release 17.11.3

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 05/27/18. So please
shout if anyone has objections.

Thanks.

	--yliu

---
>From 3a9d1792312fea4a7615255566f4991a6b730f5e Mon Sep 17 00:00:00 2001
From: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Date: Thu, 26 Apr 2018 16:09:49 +0100
Subject: [PATCH] crypto/scheduler: set null pointer after freeing

[ upstream commit 06f0a569972bebe22feeffd92c283954abc08359 ]

When freeing memory, pointers should be set to NULL,
to avoid memory corruption/segmentation faults.

Fixes: 31439ee72b2c ("crypto/scheduler: add API implementations")
Fixes: 50e14527b9d1 ("crypto/scheduler: improve parameters parsing")
Fixes: 57523e682bb7 ("crypto/scheduler: register operation functions")
Fixes: a783aa634410 ("crypto/scheduler: add packet size based mode")
Fixes: 4c07e0552f0a ("crypto/scheduler: add multicore scheduling mode")

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
---
 drivers/crypto/scheduler/rte_cryptodev_scheduler.c  | 8 ++++++--
 drivers/crypto/scheduler/scheduler_multicore.c      | 6 ++++--
 drivers/crypto/scheduler/scheduler_pkt_size_distr.c | 4 +++-
 drivers/crypto/scheduler/scheduler_pmd_ops.c        | 9 +++++++--
 4 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
index 822ce27ce..59ece9574 100644
--- a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
+++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
@@ -119,8 +119,10 @@ update_scheduler_capability(struct scheduler_ctx *sched_ctx)
 	struct rte_cryptodev_capabilities tmp_caps[256] = { {0} };
 	uint32_t nb_caps = 0, i;
 
-	if (sched_ctx->capabilities)
+	if (sched_ctx->capabilities) {
 		rte_free(sched_ctx->capabilities);
+		sched_ctx->capabilities = NULL;
+	}
 
 	for (i = 0; i < sched_ctx->nb_slaves; i++) {
 		struct rte_cryptodev_info dev_info;
@@ -490,8 +492,10 @@ rte_cryptodev_scheduler_load_user_scheduler(uint8_t scheduler_id,
 	sched_ctx->ops.option_set = scheduler->ops->option_set;
 	sched_ctx->ops.option_get = scheduler->ops->option_get;
 
-	if (sched_ctx->private_ctx)
+	if (sched_ctx->private_ctx) {
 		rte_free(sched_ctx->private_ctx);
+		sched_ctx->private_ctx = NULL;
+	}
 
 	if (sched_ctx->ops.create_private_ctx) {
 		int ret = (*sched_ctx->ops.create_private_ctx)(dev);
diff --git a/drivers/crypto/scheduler/scheduler_multicore.c b/drivers/crypto/scheduler/scheduler_multicore.c
index 0cd5bce53..8617c480e 100644
--- a/drivers/crypto/scheduler/scheduler_multicore.c
+++ b/drivers/crypto/scheduler/scheduler_multicore.c
@@ -356,11 +356,13 @@ static int
 scheduler_create_private_ctx(struct rte_cryptodev *dev)
 {
 	struct scheduler_ctx *sched_ctx = dev->data->dev_private;
-	struct mc_scheduler_ctx *mc_ctx;
+	struct mc_scheduler_ctx *mc_ctx = NULL;
 	uint16_t i;
 
-	if (sched_ctx->private_ctx)
+	if (sched_ctx->private_ctx) {
 		rte_free(sched_ctx->private_ctx);
+		sched_ctx->private_ctx = NULL;
+	}
 
 	mc_ctx = rte_zmalloc_socket(NULL, sizeof(struct mc_scheduler_ctx), 0,
 			rte_socket_id());
diff --git a/drivers/crypto/scheduler/scheduler_pkt_size_distr.c b/drivers/crypto/scheduler/scheduler_pkt_size_distr.c
index 1dd1bc321..4874191b3 100644
--- a/drivers/crypto/scheduler/scheduler_pkt_size_distr.c
+++ b/drivers/crypto/scheduler/scheduler_pkt_size_distr.c
@@ -362,8 +362,10 @@ scheduler_create_private_ctx(struct rte_cryptodev *dev)
 	struct scheduler_ctx *sched_ctx = dev->data->dev_private;
 	struct psd_scheduler_ctx *psd_ctx;
 
-	if (sched_ctx->private_ctx)
+	if (sched_ctx->private_ctx) {
 		rte_free(sched_ctx->private_ctx);
+		sched_ctx->private_ctx = NULL;
+	}
 
 	psd_ctx = rte_zmalloc_socket(NULL, sizeof(struct psd_scheduler_ctx), 0,
 			rte_socket_id());
diff --git a/drivers/crypto/scheduler/scheduler_pmd_ops.c b/drivers/crypto/scheduler/scheduler_pmd_ops.c
index d9b523524..75433db2a 100644
--- a/drivers/crypto/scheduler/scheduler_pmd_ops.c
+++ b/drivers/crypto/scheduler/scheduler_pmd_ops.c
@@ -74,6 +74,7 @@ scheduler_attach_init_slave(struct rte_cryptodev *dev)
 				sched_ctx->init_slave_names[i]);
 
 		rte_free(sched_ctx->init_slave_names[i]);
+		sched_ctx->init_slave_names[i] = NULL;
 
 		sched_ctx->nb_init_slaves -= 1;
 	}
@@ -289,11 +290,15 @@ scheduler_pmd_close(struct rte_cryptodev *dev)
 		}
 	}
 
-	if (sched_ctx->private_ctx)
+	if (sched_ctx->private_ctx) {
 		rte_free(sched_ctx->private_ctx);
+		sched_ctx->private_ctx = NULL;
+	}
 
-	if (sched_ctx->capabilities)
+	if (sched_ctx->capabilities) {
 		rte_free(sched_ctx->capabilities);
+		sched_ctx->capabilities = NULL;
+	}
 
 	return 0;
 }
-- 
2.11.0

  reply	other threads:[~2018-05-20 13:08 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-20 13:02 [dpdk-stable] patch 'event/dpaa2: remove link from info structure' " Yuanhan Liu
2018-05-20 13:02 ` Yuanhan Liu [this message]
2018-05-20 13:02 ` [dpdk-stable] patch 'crypto/scheduler: fix memory leak' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'app/crypto-perf: check minimum lcore number' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'test/reorder: fix freeing mbuf twice' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'test/distributor: fix return type of thread function' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'test/pipeline: fix return type of stub miss' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'examples/quota_watermark: fix return type of threads' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'app/testpmd: fix slave port detection' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'app/testpmd: fix valid ports prints' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'app/testpmd: fix forward ports update' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'app/testpmd: fix forward ports Rx flush' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'app/testpmd: fix synchronic port hotplug' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'app/testpmd: fix removed device link status asking' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'examples/performance-thread: fix return type of threads' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'test/pipeline: fix type of table entry parameter' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'vhost: fix dead lock on closing in server mode' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/vhost: initialise device as inactive' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/bnxt: fix Rx mbuf and agg ring leak in dev stop' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/bnxt: fix usage of vnic id' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'app/testpmd: fix empty list of RSS queues for flow' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/failsafe: fix probe cleanup' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/i40e: fix link status update' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/bonding: fix slave activation simultaneously' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'mempool: fix virtual address population' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/bnx2x: do not cast function pointers as a policy' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/bnx2x: fix KR2 device check' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/bnx2x: fix memzone name overrun' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/i40e: fix failing to disable FDIR Tx queue' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/ixgbe: fix too many interrupts' " Yuanhan Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180520130246.16287-2-yliu@fridaylinux.org \
    --to=yliu@fridaylinux.org \
    --cc=pablo.de.lara.guarch@intel.com \
    --cc=roy.fan.zhang@intel.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).