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 AF429A054F; Mon, 27 Jun 2022 19:53:12 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4BDEA40691; Mon, 27 Jun 2022 19:53:12 +0200 (CEST) Received: from out203-205-251-73.mail.qq.com (out203-205-251-73.mail.qq.com [203.205.251.73]) by mails.dpdk.org (Postfix) with ESMTP id 9AFDA40685 for ; Mon, 27 Jun 2022 19:53:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1656352385; bh=JxEL8nsJhYq6HflRSdWV2Y1cWDQFidTm8qjnYb4UMrA=; h=From:To:Cc:Subject:Date; b=qkaljnoDm90F7FntAxSs7eP2tQa6O7WA7qPVOSZheDci9L30l6Vgoia9uAm3NBuv2 FwfavbqhDTMxT7qnpox6R/enWhkLFw/8TqWTO8SaAvZtbQ2EQtD50JicPn4J3ZiYfH MD4dR2OLWkZ+DQMe4Kn1IIVOtGW0rIqOAjKIYVX4= Received: from localhost.localdomain ([240e:47c:a48:5659:7cc2:5ba2:8911:9164]) by newxmesmtplogicsvrszb6.qq.com (NewEsmtp) with SMTP id D3B90451; Tue, 28 Jun 2022 01:52:59 +0800 X-QQ-mid: xmsmtpt1656352379t08ve0x2g Message-ID: X-QQ-XMAILINFO: NUygYfydBsqcEjJK+rpJ3qsmtWkW/iCBvqVhky1NifAzi+i/AtPHlHK1OHkIyd MY1eHY1H4CAeXCl4FPKbd1OGciszneULoVECrIuhM/zLp/7iE6fHrS3iEFu/AzDYUaqpKLEfz13+ /GVEdImZbxx7MzP3vUsXW77xuOyK1q8ixKVb1gtyvzQBal8LQbrWNm8huSr9btp5KH2D+icDhqUi Mx4V3bOYjo7Zf9BZXT1Cvv9jCht/k/UIQTg7qO0a6iju4XffbaGVL11T20j+yZRnVUlqlwoFkQMD UheWCkUXgq91PthdpcjcXvKyMnYh9SSBMXtkGhII1KOThTFhyKsiwU51KY+Tx7j3VHnrSB/aDW2b 22NnYrh2d2GTJLKTY1j9xZTCki9xC3wGbGsUXvdazv7hTLxMvR+vS9S9I2ABaE8Fc3lNtHU30jb2 KhpmSeXi6vi96BuEUbFmUcGXrCkxnirdB3Tq4CKmz5QGvKcJr0g+kLVoG8LFvfZzr208Wl1VNQHY FFjHxv1tOVqO75mQVueQTT41vceVzZ5FH+NjiCMAC93IpvN1hGRgc4j1Jp9ziCL2AOV8GGKgKqag s3BD70Y52udCA6K4+paEOfa10UyG+npRqOXEHi+kVvsqwMiWotIb6fQuFgkwAnFKfed7szTdyyj2 Ue1WWUGb6/lQO/6NunomkpxXWoX/sCiHArw0m4knZ/haEIqpOdHPBy+UBqz7s0r+u++CVqtZtLEY 4MbaLBgxB3Tcwds8jjArjl57yjZj0S9dtyaB7Fw+nXaC3BW9J2btWIfKQ4LL0735Evwo/3xsyrBP COACpAEvco5+aI+bEgMZNWkwrZNXbLoPDpFdWAeIY+d0uP5UcYZqA3w+kaqYDnDyEgiEdCDRZq1Z PjwDahSBA5TTE9N0H57Sj6Uwe4BFe2m77rbOZ84rSfvFxvxmajqYYGw++ACcqfyYFNb/XQ1/yxoa cPQY9UMRzVgk9MMg+eBQ== From: 835703180@qq.com To: bruce.richardson@intel.com Cc: dev@dpdk.org, Shiqi Liu <835703180@qq.com> Subject: [PATCH] raw/ioat: Check for the NULL pointer after calling malloc Date: Tue, 28 Jun 2022 01:52:26 +0800 X-OQ-MSGID: <20220627175227.2380-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..8ab4ed5885 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