All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto/scheduler: fix uninitialized capability structure
@ 2017-04-19 15:02 Pablo de Lara
  2017-04-19 15:40 ` Zhang, Roy Fan
  0 siblings, 1 reply; 3+ messages in thread
From: Pablo de Lara @ 2017-04-19 15:02 UTC (permalink / raw)
  To: roy.fan.zhang; +Cc: dev, Pablo de Lara

Capability information is updated as slaves are attached,
but if this information is requested via rte_cryptodev_info_get()
when no slaves have been attached, the structure would not be
initialized, leading to a potential segmentation fault.

Therefore, the structure should be initialized with no
capabilities at device creation.

Fixes: 31439ee72b2c ("crypto/scheduler: add API implementations")

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 drivers/crypto/scheduler/scheduler_pmd.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/crypto/scheduler/scheduler_pmd.c b/drivers/crypto/scheduler/scheduler_pmd.c
index f2a1d2a..4ac31bb 100644
--- a/drivers/crypto/scheduler/scheduler_pmd.c
+++ b/drivers/crypto/scheduler/scheduler_pmd.c
@@ -202,6 +202,20 @@ cryptodev_scheduler_create(const char *name,
 		sched_ctx->nb_init_slaves++;
 	}
 
+	/*
+	 * Initialize capabilities structure as an empty structure,
+	 * in case device information is requested when no slaves are attached
+	 */
+	sched_ctx->capabilities = rte_zmalloc_socket(NULL,
+			sizeof(struct rte_cryptodev_capabilities),
+			0, SOCKET_ID_ANY);
+
+	if (!sched_ctx->capabilities) {
+		RTE_LOG(ERR, PMD, "Not enough memory for capability "
+				"information\n");
+		return -ENOMEM;
+	}
+
 	return 0;
 }
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] crypto/scheduler: fix uninitialized capability structure
  2017-04-19 15:02 [PATCH] crypto/scheduler: fix uninitialized capability structure Pablo de Lara
@ 2017-04-19 15:40 ` Zhang, Roy Fan
  2017-04-19 16:34   ` De Lara Guarch, Pablo
  0 siblings, 1 reply; 3+ messages in thread
From: Zhang, Roy Fan @ 2017-04-19 15:40 UTC (permalink / raw)
  To: De Lara Guarch, Pablo; +Cc: dev

> -----Original Message-----
> From: De Lara Guarch, Pablo
> Sent: Wednesday, April 19, 2017 4:02 PM
> To: Zhang, Roy Fan <roy.fan.zhang@intel.com>
> Cc: dev@dpdk.org; De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Subject: [PATCH] crypto/scheduler: fix uninitialized capability structure
> 
> Capability information is updated as slaves are attached, but if this
> information is requested via rte_cryptodev_info_get() when no slaves have
> been attached, the structure would not be initialized, leading to a potential
> segmentation fault.
> 
> Therefore, the structure should be initialized with no capabilities at device
> creation.
> 
> Fixes: 31439ee72b2c ("crypto/scheduler: add API implementations")
> 
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>

Acked-by: Fan Zhang <roy.fan.zhang@intel.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] crypto/scheduler: fix uninitialized capability structure
  2017-04-19 15:40 ` Zhang, Roy Fan
@ 2017-04-19 16:34   ` De Lara Guarch, Pablo
  0 siblings, 0 replies; 3+ messages in thread
From: De Lara Guarch, Pablo @ 2017-04-19 16:34 UTC (permalink / raw)
  To: Zhang, Roy Fan; +Cc: dev



> -----Original Message-----
> From: Zhang, Roy Fan
> Sent: Wednesday, April 19, 2017 4:41 PM
> To: De Lara Guarch, Pablo
> Cc: dev@dpdk.org
> Subject: RE: [PATCH] crypto/scheduler: fix uninitialized capability structure
> 
> > -----Original Message-----
> > From: De Lara Guarch, Pablo
> > Sent: Wednesday, April 19, 2017 4:02 PM
> > To: Zhang, Roy Fan <roy.fan.zhang@intel.com>
> > Cc: dev@dpdk.org; De Lara Guarch, Pablo
> <pablo.de.lara.guarch@intel.com>
> > Subject: [PATCH] crypto/scheduler: fix uninitialized capability structure
> >
> > Capability information is updated as slaves are attached, but if this
> > information is requested via rte_cryptodev_info_get() when no slaves
> have
> > been attached, the structure would not be initialized, leading to a
> potential
> > segmentation fault.
> >
> > Therefore, the structure should be initialized with no capabilities at device
> > creation.
> >
> > Fixes: 31439ee72b2c ("crypto/scheduler: add API implementations")
> >
> > Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> 
> Acked-by: Fan Zhang <roy.fan.zhang@intel.com>

Applied to dpdk-next-crypto.

Pablo

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-04-19 16:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-19 15:02 [PATCH] crypto/scheduler: fix uninitialized capability structure Pablo de Lara
2017-04-19 15:40 ` Zhang, Roy Fan
2017-04-19 16:34   ` De Lara Guarch, Pablo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.