* [dpdk-dev] [PATCH] malloc: fix potential null pointer dereference
@ 2018-08-15 7:20 Tiwei Bie
2018-08-15 8:56 ` Burakov, Anatoly
0 siblings, 1 reply; 3+ messages in thread
From: Tiwei Bie @ 2018-08-15 7:20 UTC (permalink / raw)
To: anatoly.burakov, dev
We need to do the NULL pointer check first after malloc().
Fixes: 07dcbfe0101f ("malloc: support multiprocess memory hotplug")
Cc: stable@dpdk.org
Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
---
lib/librte_eal/common/malloc_heap.c | 4 +---
lib/librte_eal/common/malloc_mp.c | 4 +---
2 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/lib/librte_eal/common/malloc_heap.c b/lib/librte_eal/common/malloc_heap.c
index 12aaf2d72..ac7bbb3ba 100644
--- a/lib/librte_eal/common/malloc_heap.c
+++ b/lib/librte_eal/common/malloc_heap.c
@@ -326,11 +326,9 @@ try_expand_heap_primary(struct malloc_heap *heap, uint64_t pg_sz,
/* we can't know in advance how many pages we'll need, so we malloc */
ms = malloc(sizeof(*ms) * n_segs);
-
- memset(ms, 0, sizeof(*ms) * n_segs);
-
if (ms == NULL)
return -1;
+ memset(ms, 0, sizeof(*ms) * n_segs);
elem = alloc_pages_on_heap(heap, pg_sz, elt_size, socket, flags, align,
bound, contig, ms, n_segs);
diff --git a/lib/librte_eal/common/malloc_mp.c b/lib/librte_eal/common/malloc_mp.c
index 931c14bc5..5f2d4e0be 100644
--- a/lib/librte_eal/common/malloc_mp.c
+++ b/lib/librte_eal/common/malloc_mp.c
@@ -194,13 +194,11 @@ handle_alloc_request(const struct malloc_mp_req *m,
/* we can't know in advance how many pages we'll need, so we malloc */
ms = malloc(sizeof(*ms) * n_segs);
-
- memset(ms, 0, sizeof(*ms) * n_segs);
-
if (ms == NULL) {
RTE_LOG(ERR, EAL, "Couldn't allocate memory for request state\n");
goto fail;
}
+ memset(ms, 0, sizeof(*ms) * n_segs);
elem = alloc_pages_on_heap(heap, ar->page_sz, ar->elt_size, ar->socket,
ar->flags, ar->align, ar->bound, ar->contig, ms,
--
2.18.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [PATCH] malloc: fix potential null pointer dereference
2018-08-15 7:20 [dpdk-dev] [PATCH] malloc: fix potential null pointer dereference Tiwei Bie
@ 2018-08-15 8:56 ` Burakov, Anatoly
2018-09-16 9:24 ` Thomas Monjalon
0 siblings, 1 reply; 3+ messages in thread
From: Burakov, Anatoly @ 2018-08-15 8:56 UTC (permalink / raw)
To: Tiwei Bie, dev
On 15-Aug-18 8:20 AM, Tiwei Bie wrote:
> We need to do the NULL pointer check first after malloc().
>
> Fixes: 07dcbfe0101f ("malloc: support multiprocess memory hotplug")
> Cc: stable@dpdk.org
>
> Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
> ---
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
--
Thanks,
Anatoly
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [PATCH] malloc: fix potential null pointer dereference
2018-08-15 8:56 ` Burakov, Anatoly
@ 2018-09-16 9:24 ` Thomas Monjalon
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2018-09-16 9:24 UTC (permalink / raw)
To: Tiwei Bie; +Cc: dev, Burakov, Anatoly
15/08/2018 10:56, Burakov, Anatoly:
> On 15-Aug-18 8:20 AM, Tiwei Bie wrote:
> > We need to do the NULL pointer check first after malloc().
> >
> > Fixes: 07dcbfe0101f ("malloc: support multiprocess memory hotplug")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
>
> Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
Applied, thanks
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-09-16 9:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-15 7:20 [dpdk-dev] [PATCH] malloc: fix potential null pointer dereference Tiwei Bie
2018-08-15 8:56 ` Burakov, Anatoly
2018-09-16 9:24 ` Thomas Monjalon
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).