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 62BC6A0540; Wed, 6 Jul 2022 08:57:36 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ED5E440DF7; Wed, 6 Jul 2022 08:57:35 +0200 (CEST) Received: from out162-62-57-210.mail.qq.com (out162-62-57-210.mail.qq.com [162.62.57.210]) by mails.dpdk.org (Postfix) with ESMTP id 8695540691 for ; Wed, 6 Jul 2022 08:57:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1657090644; bh=0bq59i870ZntzFmEP3tIFX6pUId5GEJX6sT/UnDfdEE=; h=From:To:Cc:Subject:Date; b=fdCo4cEhJEQkIb/6VnxRqwRRYS1GCy7lB+21nH+YK+iMhwY7PEFsobV7la9CjakHY SmfFn+GtvrApKSemUbircwH6dAJUXCLdsggKBi/l7P+hrljVq3NltlbOOil+o44EGL x2W7uDxJLldZO8FfTYgC4K59PTO52Tfoqx25vEUg= Received: from localhost.localdomain ([183.236.0.94]) by newxmesmtplogicsvrszc10.qq.com (NewEsmtp) with SMTP id E4DB70CD; Wed, 06 Jul 2022 14:57:13 +0800 X-QQ-mid: xmsmtpt1657090633tzox8dylu Message-ID: X-QQ-XMAILINFO: NDz66ktblfzJyCA6jvHx+w4Z957F611o674eX+4rd7TpQKiBVR9/epQGCcVHI7 udBWh8sykNLr2K5lCKDP4kihP51ZPZBERoUPGC3akf7GfJzeIvtV9YIBOgk4CBVdJm+UkSQyPmoz PfeN2MUyYvSs+Yq0YU/7wMNzOzKdXV5Mku0MTjANVPAD7AsPx2Hmrdysvjm5ZMGKcGAajixtYxGG /Cn4429zicszAUM+lAiZt/kVkUGTIKS4eVvGGeMWFrlMEwK78230ugTuO2S0Hk46uWeGf4xyjPnw SVfsbv4vh4+SJMswgFHI0aGd3QAyXGHQGcAhuHvRBKKvKDSp5OIi7QcAPLOmZcvpH6lYEJFo+p8/ L4tDiuSU1HnB+msOBPLC4Drp/FcsL1fDofbd8aVINsemQaIMoEkPi/X4q/IJgJpd5WvnOW739tNH eVjPafFs1yN/msWetP+GUsgW6f9w92/iDaAI8n9/ZsSMGt1eCHZJ4iKYc9H/bm/xS/ZC2Qs3Hgp1 muLcanQVETPEQtZ4Rdi83WTLwHwdHnI0aLbdlpxjzxxMUDtuDf2+sT3YdWQpII2P98TDQIwH4vlz qUHeRJaacLI69ypw4DJ6xpyQ/rZ2U+sVNZjl/BqSVLRP+rlkoDqL2Rxe0WED2+MVHTJ+0EW55uPg APuRf9hW1zpI3YvS5KyfWyHORscKRhh6m2WOSFrgpRMWdmGJrgYlp9ngjRQQ3gyk90dYaL/xv1uX LcAkmu4OFVUTwtbyCHySelioukNj/rItin/Yp+3/rJ5225NsPOHGun0HkCfA7IxJgkdF6hDGYy+P lI0Lz8Qz63jW2heayh4pCr8PGuSQgp4O6VkxVRltA+XTrZGsXX+qzkN5vy2mKx/3X3n5HEVC5bO1 c8W6GjPe/Mx/GhIFL8sYDi/QZh4IhV0PWgo7PMLGA1R7KRLmmnhQ4= From: 835703180@qq.com To: bruce.richardson@intel.com Cc: dev@dpdk.org, Shiqi Liu <835703180@qq.com> Subject: [PATCH V2] raw/ioat: Check for the NULL pointer after calling malloc Date: Wed, 6 Jul 2022 14:55:48 +0800 X-OQ-MSGID: <20220706065547.1520-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: b7aaf417f93 ("raw/ioat: add bus driver for device scanning automatically") Signed-off-by: Shiqi Liu <835703180@qq.com> --- drivers/raw/ioat/idxd_bus.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/raw/ioat/idxd_bus.c b/drivers/raw/ioat/idxd_bus.c index 539f51b1b1..ba2bbe0f7e 100644 --- a/drivers/raw/ioat/idxd_bus.c +++ b/drivers/raw/ioat/idxd_bus.c @@ -301,6 +301,10 @@ dsa_scan(void) IOAT_PMD_DEBUG("%s(): found %s/%s", __func__, path, wq->d_name); dev = malloc(sizeof(*dev)); + if (dev == NULL) { + closedir(dev_dir); + return -ENOMEM; + } if (dsa_addr_parse(wq->d_name, &dev->addr) < 0) { IOAT_PMD_ERR("Error parsing WQ name: %s", wq->d_name); free(dev); -- 2.35.1.windows.2