mbuf: fix error code in dynamic field/flag registration
authorXiaolong Ye <xiaolong.ye@intel.com>
Sat, 13 Jun 2020 15:49:18 +0000 (23:49 +0800)
committerThomas Monjalon <thomas@monjalon.net>
Thu, 25 Jun 2020 21:03:18 +0000 (23:03 +0200)
Set rte_errno as ENOMEM when allocation failure.

Fixes: 4958ca3a443a ("mbuf: support dynamic fields and flags")
Cc: stable@dpdk.org
Signed-off-by: Xiaolong Ye <xiaolong.ye@intel.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
lib/librte_mbuf/rte_mbuf_dyn.c

index 13d6da6..de7d2eb 100644 (file)
@@ -278,12 +278,15 @@ __rte_mbuf_dynfield_register_offset(const struct rte_mbuf_dynfield *params,
                mbuf_dynfield_tailq.head, mbuf_dynfield_list);
 
        te = rte_zmalloc("MBUF_DYNFIELD_TAILQ_ENTRY", sizeof(*te), 0);
-       if (te == NULL)
+       if (te == NULL) {
+               rte_errno = ENOMEM;
                return -1;
+       }
 
        mbuf_dynfield = rte_zmalloc("mbuf_dynfield", sizeof(*mbuf_dynfield), 0);
        if (mbuf_dynfield == NULL) {
                rte_free(te);
+               rte_errno = ENOMEM;
                return -1;
        }
 
@@ -456,12 +459,15 @@ __rte_mbuf_dynflag_register_bitnum(const struct rte_mbuf_dynflag *params,
                mbuf_dynflag_tailq.head, mbuf_dynflag_list);
 
        te = rte_zmalloc("MBUF_DYNFLAG_TAILQ_ENTRY", sizeof(*te), 0);
-       if (te == NULL)
+       if (te == NULL) {
+               rte_errno = ENOMEM;
                return -1;
+       }
 
        mbuf_dynflag = rte_zmalloc("mbuf_dynflag", sizeof(*mbuf_dynflag), 0);
        if (mbuf_dynflag == NULL) {
                rte_free(te);
+               rte_errno = ENOMEM;
                return -1;
        }