From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 89494A0540; Thu, 7 Jul 2022 11:25:08 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1D1A240A7B; Thu, 7 Jul 2022 11:25:08 +0200 (CEST) Received: from out162-62-57-137.mail.qq.com (out162-62-57-137.mail.qq.com [162.62.57.137]) by mails.dpdk.org (Postfix) with ESMTP id 84CE2406B4 for ; Thu, 7 Jul 2022 11:25:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1657185903; bh=dreT1QvfloOPc8wfrlJNWqPda2AjTyU4CRDrIUdrqg0=; h=From:To:Cc:Subject:Date; b=IY27mZl7uIOQmtP0F7x3EgFbiUdF4lAsia/rciP/LYff+xlHfjQLoUZ3GXYObeeob oMkuvKKwMbMM5QgMk6QpF8NnX3qK/nAbdPQLidxZUBJoj8zsuzaMes8ldC+SXwI52e frj07RESazKZXWcXrcwKA5zfXiVGrR1uFA6UtbL0= Received: from localhost.localdomain ([183.236.0.94]) by newxmesmtplogicsvrsza32.qq.com (NewEsmtp) with SMTP id 63401666; Thu, 07 Jul 2022 17:24:52 +0800 X-QQ-mid: xmsmtpt1657185892tgphigd8a Message-ID: X-QQ-XMAILINFO: NDgMZBR9sMmaNUAXP3CkLSf/nntn5GILXkZSpVi3onYUUgeRV4eX1Q8vUNu50c dJqfEZeQc5tJMg/s/bAQClGwieD+mvPCje7h/Ul5eU4XNb0OvwN8ZycizensCBqkbP5GYgzUh10w 0R+lJIB0s8+tKpIwLvPb/MsdFzfESYnUz33ovajmOcTQKZgx0vLIWKrtP0FHmGsFHVcG22A2vz1U AduWEBfPHxxGM2H9qIxD/nU8eYBOdofFtwUP91HOTdPRBy2KiJloSte8SVzVpWSgDSGQOItnaA3a oFGJOcBZNEbyXsX7Zx2Da01idu0tm8b34U1fS1QWzvlTO9QaoyoPXlxhWJNcwUFqRqBhLRJb0aDB 6Ja1+8XoXeSCW5vYqMh1VHA2orfSJErnWiyKQ5oWkAPfHflY+lCSL6Qw57UNh5i0fhkKWk3buB79 Pw+WNSUlodNFW2TgG/tUqvLa2H1LOolQ7/KN0TPeO+xUlH82bMv5EAEd2PMeJ4HFiyvZY6spqw3e edSIetpSUQ8+3ZrY+/EiaVWQNx6covH/QqWXDlf0aqedO63wxoopXNFJP5VKac2uvTnbeyZ0uBp4 GezEkOCUay20nF8sEgLYitJ07aGc2lTTU4o9sLDi4Qmw0vu+sCYh26YpM6OTyYvPfmOHcmMyI74t xi48s141R6nTuNjzMPTbhG8Ngo8LZCvMcH0TXifFpaaokxFmnSUMDH+Tcuk69bzSAKtYUJWfnyq2 e/1fjyL1RBRcLUybk7TgkIPf/YoSWt/jVuPJurf4fGho9g1zyJPRVExspQslw0yQlmvAyNCCvGJr MAvHTvjx2QROgExJUgtOTHzD0jRrs2A5juxAy44lD9fZpMQcVt+hdh1VfzIVrJJNMzVI5bhWj7Td vdor5RXfolk5naE7uSBgmzv6/4C4JrYGGAfb+ddjrdR5wyA/nAp6MbaGf9oB9i7g== From: 835703180@qq.com To: pbhagavatula@marvell.com Cc: dev@dpdk.org, Shiqi Liu <835703180@qq.com> Subject: [PATCH] lib: Check for the NULL pointer after calling malloc Date: Thu, 7 Jul 2022 17:23:45 +0800 X-OQ-MSGID: <20220707092344.991-1-835703180@qq.com> X-Mailer: git-send-email 2.35.1.windows.2 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Shiqi Liu <835703180@qq.com> As the possible failure of the malloc(), the not_checked and checked could be NULL pointer. Therefore, it should be better to check it in order to avoid the dereference of the NULL pointer. Fixes: fa8054c8c88 ("lib/node: add ethdev control") Signed-off-by: Shiqi Liu <835703180@qq.com> --- lib/node/ethdev_ctrl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/node/ethdev_ctrl.c b/lib/node/ethdev_ctrl.c index 5294607619..eef0785c21 100644 --- a/lib/node/ethdev_ctrl.c +++ b/lib/node/ethdev_ctrl.c @@ -75,6 +75,9 @@ rte_node_eth_config(struct rte_node_ethdev_config *conf, uint16_t nb_confs, /* Add it to list of ethdev rx nodes for lookup */ elem = malloc(sizeof(ethdev_rx_node_elem_t)); + if (elem == NULL) { + return -ENOMEM; + } memset(elem, 0, sizeof(ethdev_rx_node_elem_t)); elem->ctx.port_id = port_id; elem->ctx.queue_id = j; -- 2.35.1.windows.2