[1/1] mem: check allocation in dynamic hugepage init
Checks
Commit Message
The function malloc() could return NULL, the return value
need to be checked.
Fixes: 694161b7e065 ("mem: extract common dynamic memory allocation")
Cc: stable@dpdk.org
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
lib/eal/common/eal_common_dynmem.c | 4 ++++
1 file changed, 4 insertions(+)
Comments
On Tue, Dec 14, 2021 at 2:30 PM Yunjian Wang <wangyunjian@huawei.com> wrote:
>
> The function malloc() could return NULL, the return value
> need to be checked.
>
> Fixes: 694161b7e065 ("mem: extract common dynamic memory allocation")
> Cc: stable@dpdk.org
>
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
On Sat, Feb 5, 2022 at 6:29 PM David Marchand <david.marchand@redhat.com> wrote:
>
> On Tue, Dec 14, 2021 at 2:30 PM Yunjian Wang <wangyunjian@huawei.com> wrote:
> >
> > The function malloc() could return NULL, the return value
> > need to be checked.
> >
> > Fixes: 694161b7e065 ("mem: extract common dynamic memory allocation")
That's actually introduced with:
Fixes: 6f63858e55e6 ("mem: prevent preallocated pages from being freed")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> Reviewed-by: David Marchand <david.marchand@redhat.com>
Applied, thanks.
@@ -304,6 +304,10 @@ eal_dynmem_hugepage_init(void)
needed = num_pages - num_pages_alloc;
pages = malloc(sizeof(*pages) * needed);
+ if (pages == NULL) {
+ RTE_LOG(ERR, EAL, "Failed to malloc pages\n");
+ return -1;
+ }
/* do not request exact number of pages */
cur_pages = eal_memalloc_alloc_seg_bulk(pages,