Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/129425/?format=api
https://patches.dpdk.org/api/patches/129425/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/20230710170800.12478-5-stephen@networkplumber.org/", "project": { "id": 1, "url": "https://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20230710170800.12478-5-stephen@networkplumber.org>", "list_archive_url": "https://inbox.dpdk.org/dev/20230710170800.12478-5-stephen@networkplumber.org", "date": "2023-07-10T17:07:59", "name": "[v4,4/5] malloc: codeql fixes", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "d8971e3a59ffe92a2f6882fe2a53950c1d046f35", "submitter": { "id": 27, "url": "https://patches.dpdk.org/api/people/27/?format=api", "name": "Stephen Hemminger", "email": "stephen@networkplumber.org" }, "delegate": { "id": 1, "url": "https://patches.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "https://patches.dpdk.org/project/dpdk/patch/20230710170800.12478-5-stephen@networkplumber.org/mbox/", "series": [ { "id": 28886, "url": "https://patches.dpdk.org/api/series/28886/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=28886", "date": "2023-07-10T17:07:55", "name": "fixes for problems found by codeql analyzer", "version": 4, "mbox": "https://patches.dpdk.org/series/28886/mbox/" } ], "comments": "https://patches.dpdk.org/api/patches/129425/comments/", "check": "success", "checks": "https://patches.dpdk.org/api/patches/129425/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 6800342E3C;\n\tMon, 10 Jul 2023 19:08:31 +0200 (CEST)", "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id F02F942D1D;\n\tMon, 10 Jul 2023 19:08:10 +0200 (CEST)", "from mail-pf1-f170.google.com (mail-pf1-f170.google.com\n [209.85.210.170])\n by mails.dpdk.org (Postfix) with ESMTP id D417E40150\n for <dev@dpdk.org>; Mon, 10 Jul 2023 19:08:07 +0200 (CEST)", "by mail-pf1-f170.google.com with SMTP id\n d2e1a72fcca58-6686a05bc66so2609965b3a.1\n for <dev@dpdk.org>; Mon, 10 Jul 2023 10:08:07 -0700 (PDT)", "from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218])\n by smtp.gmail.com with ESMTPSA id\n q17-20020a62e111000000b00682ed27f99dsm51799pfh.46.2023.07.10.10.08.06\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Mon, 10 Jul 2023 10:08:06 -0700 (PDT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1689008887;\n x=1691600887;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=R92bKE5RrcnOxuzq2w4Wy8obvQQT5MGY0zBIIbenUk4=;\n b=sXHrt0nr6ba6KY8uhgr2iiytI+0Jk/e4OxNkd4E0N30SwZqHF3dCuAmbLSnL9x/gX8\n gVF2y87QCiRyHrIDYlmlR/exA394j06kMdhu8yQKSdKRnQpOqw2hOCqDWr5njd+k9fkR\n 5O7E4y1nX6fEvtZVld2/MIpuvGkmsYXZagAG1Zh/WyDDt22Oijamq6QAwda9mDU4tM/V\n /JntZ+cQ5BNvxTaC7nTK14tr1MNNOK374nx5/26l8m4Toit776HE4wLgUXyuamJyI6qQ\n mOuU9Bhd7Zs//fbwJizhbmvlcdJ2Yoaz45M7XGeFCkvRsc8dvo1oypt9L20IswxNkC4N\n 6Y/Q==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20221208; t=1689008887; x=1691600887;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n :subject:date:message-id:reply-to;\n bh=R92bKE5RrcnOxuzq2w4Wy8obvQQT5MGY0zBIIbenUk4=;\n b=F5oZcph9ticpG7kzKcUo8SAU/ze8Fe+gQcHRudP71Aa50AeOLB3oRJOt8xh5Blj+Qz\n m6hp1D2utW9sw7xHeb5lP8s7KEq2Ap8xohnblgVqvXkEJjXtbvffvo0/k1Pi0kk90Brh\n OfkCl2e4PqzcY4sDZKMs+ev2pGOmr5VmaWc8Bqv5e3GtidLfafApwUPaSaQsVkP9YoMM\n Lrq9/x+EgmsoEagZsywTxuLbhcc2tU4clB2EDlmGqNfYwsaYP7OKKI0Yx3gLEBkdflP5\n /Gj4RoKmWvgduCzq9neV1m80rbocgb56bmfZg7/jGgUkMwwg1wixQtqEvm4t11/c1ZOz\n R4eQ==", "X-Gm-Message-State": "ABy/qLZHz7IqM6JAKHf7c4QdVRbTQizLGlO6aPgfdIZU0+vlNWC6iaR7\n ORu0oGw0QdyOFzRSaczJh33hsVEMnXMhtdmCAg3gNA==", "X-Google-Smtp-Source": "\n APBJJlGbEz1oDk7LBo2sQJ2AjjEZpU8J/sZ+at+InrFdZEEa7OGjsYeTzWeNpo43FPbKlEpKTE9mwQ==", "X-Received": "by 2002:a05:6a20:1018:b0:12f:7a6a:7f8e with SMTP id\n gs24-20020a056a20101800b0012f7a6a7f8emr10416174pzc.13.1689008886796;\n Mon, 10 Jul 2023 10:08:06 -0700 (PDT)", "From": "Stephen Hemminger <stephen@networkplumber.org>", "To": "dev@dpdk.org", "Cc": "Sinan Kaya <okaya@kernel.org>,\n Stephen Hemminger <stephen@networkplumber.org>,\n Anatoly Burakov <anatoly.burakov@intel.com>", "Subject": "[PATCH v4 4/5] malloc: codeql fixes", "Date": "Mon, 10 Jul 2023 10:07:59 -0700", "Message-Id": "<20230710170800.12478-5-stephen@networkplumber.org>", "X-Mailer": "git-send-email 2.39.2", "In-Reply-To": "<20230710170800.12478-1-stephen@networkplumber.org>", "References": "<20230120044140.95975-1-okaya@kernel.org>\n <20230710170800.12478-1-stephen@networkplumber.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org" }, "content": "From: Sinan Kaya <okaya@kernel.org>\n\nIn malloc_heap_add_memory result of call to malloc_elem_join_adjacent_free\nis dereferenced here and may be null.\n\nIn alloc_pages_on_heap result of call to rte_mem_virt2memseg_list\nis dereferenced here and may be null.\n\nIn eal_memalloc_is_contig result of call to rte_fbarray_get\nis dereferenced here and may be null.\n\nIn malloc_elem_find_max_iova_contig result of call to rte_mem_virt2memseg\nis dereferenced here and may be null.\n\nIn malloc_heap_free result of call to malloc_elem_free is dereferenced\nhere and may be null.\n\nIn malloc_elem_alloc result of call to elem_start_pt is dereferenced\nhere and may be null.\n\nSigned-off-by: Sinan Kaya <okaya@kernel.org>\nSigned-off-by: Stephen Hemminger <stephen@networkplumber.org>\n---\n lib/eal/common/eal_common_memalloc.c | 5 ++++-\n lib/eal/common/malloc_elem.c | 14 +++++++++++---\n lib/eal/common/malloc_heap.c | 9 ++++++++-\n 3 files changed, 23 insertions(+), 5 deletions(-)", "diff": "diff --git a/lib/eal/common/eal_common_memalloc.c b/lib/eal/common/eal_common_memalloc.c\nindex ab04479c1cc5..24506f8447d7 100644\n--- a/lib/eal/common/eal_common_memalloc.c\n+++ b/lib/eal/common/eal_common_memalloc.c\n@@ -126,6 +126,9 @@ eal_memalloc_is_contig(const struct rte_memseg_list *msl, void *start,\n \n \t\t/* skip first iteration */\n \t\tms = rte_fbarray_get(&msl->memseg_arr, start_seg);\n+\t\tif (ms == NULL)\n+\t\t\treturn false;\n+\n \t\tcur = ms->iova;\n \t\texpected = cur + pgsz;\n \n@@ -137,7 +140,7 @@ eal_memalloc_is_contig(const struct rte_memseg_list *msl, void *start,\n \t\t\t\tcur_seg++, expected += pgsz) {\n \t\t\tms = rte_fbarray_get(&msl->memseg_arr, cur_seg);\n \n-\t\t\tif (ms->iova != expected)\n+\t\t\tif ((ms != NULL) && (ms->iova != expected))\n \t\t\t\treturn false;\n \t\t}\n \t}\ndiff --git a/lib/eal/common/malloc_elem.c b/lib/eal/common/malloc_elem.c\nindex 619c040aa3e8..443ae26d283a 100644\n--- a/lib/eal/common/malloc_elem.c\n+++ b/lib/eal/common/malloc_elem.c\n@@ -63,6 +63,8 @@ malloc_elem_find_max_iova_contig(struct malloc_elem *elem, size_t align)\n \n \tcur_page = RTE_PTR_ALIGN_FLOOR(contig_seg_start, page_sz);\n \tms = rte_mem_virt2memseg(cur_page, elem->msl);\n+\tif (ms == NULL)\n+\t\treturn 0;\n \n \t/* do first iteration outside the loop */\n \tpage_end = RTE_PTR_ADD(cur_page, page_sz);\n@@ -91,9 +93,12 @@ malloc_elem_find_max_iova_contig(struct malloc_elem *elem, size_t align)\n \t\t\t * we're not blowing past data end.\n \t\t\t */\n \t\t\tms = rte_mem_virt2memseg(contig_seg_start, elem->msl);\n-\t\t\tcur_page = ms->addr;\n-\t\t\t/* don't trigger another recalculation */\n-\t\t\texpected_iova = ms->iova;\n+\t\t\tif (ms != NULL) {\n+\t\t\t\tcur_page = ms->addr;\n+\n+\t\t\t\t/* don't trigger another recalculation */\n+\t\t\t\texpected_iova = ms->iova;\n+\t\t\t}\n \t\t\tcontinue;\n \t\t}\n \t\t/* cur_seg_end ends on a page boundary or on data end. if we're\n@@ -430,6 +435,9 @@ malloc_elem_alloc(struct malloc_elem *elem, size_t size, unsigned align,\n {\n \tstruct malloc_elem *new_elem = elem_start_pt(elem, size, align, bound,\n \t\t\tcontig);\n+\tif (new_elem == NULL)\n+\t\treturn NULL;\n+\n \tconst size_t old_elem_size = (uintptr_t)new_elem - (uintptr_t)elem;\n \tconst size_t trailer_size = elem->size - old_elem_size - size -\n \t\tMALLOC_ELEM_OVERHEAD;\ndiff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c\nindex 6b6cf9174cd3..0abaaa8c57f8 100644\n--- a/lib/eal/common/malloc_heap.c\n+++ b/lib/eal/common/malloc_heap.c\n@@ -97,6 +97,8 @@ malloc_heap_add_memory(struct malloc_heap *heap, struct rte_memseg_list *msl,\n \tmalloc_elem_insert(elem);\n \n \telem = malloc_elem_join_adjacent_free(elem);\n+\tif (elem == NULL)\n+\t\treturn NULL;\n \n \tmalloc_elem_free_list_insert(elem);\n \n@@ -321,6 +323,8 @@ alloc_pages_on_heap(struct malloc_heap *heap, uint64_t pg_sz, size_t elt_size,\n \n \tmap_addr = ms[0]->addr;\n \tmsl = rte_mem_virt2memseg_list(map_addr);\n+\tif (msl == NULL)\n+\t\treturn NULL;\n \n \t/* check if we wanted contiguous memory but didn't get it */\n \tif (contig && !eal_memalloc_is_contig(msl, map_addr, alloc_sz)) {\n@@ -897,6 +901,9 @@ malloc_heap_free(struct malloc_elem *elem)\n \t/* anything after this is a bonus */\n \tret = 0;\n \n+\tif (elem == NULL)\n+\t\tgoto free_unlock;\n+\n \t/* ...of which we can't avail if we are in legacy mode, or if this is an\n \t * externally allocated segment.\n \t */\n@@ -935,7 +942,7 @@ malloc_heap_free(struct malloc_elem *elem)\n \t\tconst struct rte_memseg *tmp =\n \t\t\t\trte_mem_virt2memseg(aligned_start, msl);\n \n-\t\tif (tmp->flags & RTE_MEMSEG_FLAG_DO_NOT_FREE) {\n+\t\tif ((tmp != NULL) && (tmp->flags & RTE_MEMSEG_FLAG_DO_NOT_FREE)) {\n \t\t\t/* this is an unfreeable segment, so move start */\n \t\t\taligned_start = RTE_PTR_ADD(tmp->addr, tmp->len);\n \t\t}\n", "prefixes": [ "v4", "4/5" ] }{ "id": 129425, "url": "