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 73B36A0544; Tue, 5 Jul 2022 21:43:42 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0834840223; Tue, 5 Jul 2022 21:43:42 +0200 (CEST) Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by mails.dpdk.org (Postfix) with ESMTP id 14A18400D7 for ; Tue, 5 Jul 2022 21:43:40 +0200 (CEST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id CBA4F3200927; Tue, 5 Jul 2022 15:43:36 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 05 Jul 2022 15:43:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1657050216; x= 1657136616; bh=R5+v805ENa83TtJoGvf8cVW3woES6A+oIFe08y/VaKM=; b=T tNS+2mEEUtBdTUdpGmwyFa1e/cTJhVjTl1BvAU59MyC1KWuFmTOk90w+udyAg31V vzJR35HuO5VKi/XNrK1gz6uObEZcdXs9K5n48mAJui97xtKIDXuGoGN0Wu7cGgFP 2G7TEj5inoFZ1OIzYGRfH/8SkNspZd8c7uJJ7VGTLW42NcHDKIJEk7nW9UVjz5xk KWb2tDZ4heJLaQclHGxc7ATokoTvy1OJ836HnjVG0k/OcPKpoPYxI/WK5uxm8Jwh kQomJyi5UsPKzWa+sV88QirtC5yDqSbfTz4sKi/BPi6FMiFfNoQERepJt8lwIF2T k8r/jqqyj2/YjVcUonlxw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1657050216; x= 1657136616; bh=R5+v805ENa83TtJoGvf8cVW3woES6A+oIFe08y/VaKM=; b=G x/z1NW2TSaBDM2AwnhSwQMU5xLeUaR9mXd2/DWZM4PpKspYOIxfgEooFbMy14sgP 66VfY9wvt7wuz0t1mZuZPQk3gvqVg9aaK0TiXyiIvP3faiXd0YJ5hFtpSyPKecUj cvCWe4enjFD2RIqiB+heE4xGMboyU/0IX57uLldRrBC/sn3nFKaJmR4PH7Fxy6nV 02bXLeOo71ec10eB3PbtheYd8eSocq5yMEh8bF6uM3gqzM+ZG9OMrRxJRBLvBo8R W0ncgbE58gZ7y4XGADaP5EZmztZMs7vc3uWlJqzrOQsS3Lly9qR9OS0ia6Z5CAJZ qNJfqIxhMVHMDIMnm+oFw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudeiuddgudeghecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkjghfggfgtgesth furedttddtvdenucfhrhhomhepvfhhohhmrghsucfoohhnjhgrlhhonhcuoehthhhomhgr shesmhhonhhjrghlohhnrdhnvghtqeenucggtffrrghtthgvrhhnpedtjeeiieefhedtff fgvdelteeufeefheeujefgueetfedttdeikefgkeduhedtgfenucevlhhushhtvghrufhi iigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghloh hnrdhnvght X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 5 Jul 2022 15:43:35 -0400 (EDT) From: Thomas Monjalon To: Shiqi Liu <835703180@qq.com> Cc: bruce.richardson@intel.com, dev@dpdk.org Subject: Re: [PATCH] raw/ioat: Check for the NULL pointer after calling malloc Date: Tue, 05 Jul 2022 21:43:34 +0200 Message-ID: <7856744.uz5P2jW1tq@thomas> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" 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 27/06/2022 19:52, 835703180@qq.com: > 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> > --- > --- 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; Isn't it supposed to be a negative value?