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 02FA5A0587; Wed, 19 Oct 2022 16:02:26 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B94A642B6C; Wed, 19 Oct 2022 16:02:26 +0200 (CEST) Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) by mails.dpdk.org (Postfix) with ESMTP id C36C8410D1 for ; Wed, 19 Oct 2022 16:02:25 +0200 (CEST) Received: by mail-wm1-f49.google.com with SMTP id bh7-20020a05600c3d0700b003c6fb3b2052so72893wmb.2 for ; Wed, 19 Oct 2022 07:02:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CnNZzug3jZjk+H/4cA/xi2RKomHEIL308AcbNwjOMpg=; b=tYqfMQdjxwtAw1G02D3lnJyMNVBSC7QCKDJYILYpEtnUcAaAsNqMdYn1cOYmf9kuKl /Ug9t723xfjTZJKRZMpIZaj5NS0KqSt/eVlW+iMCtWYMSBcw2+gCCbhmXfiYbma0GPgB D2QSObD8uyrIpCX22ymu7iENR7qt2SkNY/LZenclFMUKYO9oZQG/QsIyFmxdFcs4u8yo A7x1x0tmDTMNYCH2xVEKXOoD99g1zGvksOS1U9+K48haGY4dv7Aw53rYECi+qrCilZHe Rv7KKriS/Ve/iUO6mQjTO1NrNhhrwEdZlsfUDvjQnfXnbDI+AHyMjk/26o7NIjztiXpg OW1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CnNZzug3jZjk+H/4cA/xi2RKomHEIL308AcbNwjOMpg=; b=iYQYA1H0HVB7mK8CWNNAh6hwJclAPgyk4n4pXKlxW9DGlVW0kmiKkIHhw+yaNiED3T ZSLP34vDfuVnyvp1rGUfdi+M/QVrF1TKJ0GGR0YyyMm6hm6U1bWj6/tLYHE/EEFxfv49 hbV78+QQgdOa1SVysZk08JWSqAis8mSgXynCC1irdO2e0IXTugQ/UxpnAfXW1HId/Ite o6eTTYIZlH1muo12HhtSw3okznd96iVZHa0rgVsUTTvuseKItaNSK7vFTc6vSKA00G2X z7U0NBfZP1OYngULDEULCPk6kkqf2tDI2Vp6/vvUu6lPDMFbngLhSkcoAt3fvgVF3srx d0Tw== X-Gm-Message-State: ACrzQf0m5ke6GXaCQuknBF842yl3MGEvt8q09MTQOeHPUMFZDpXmN7e7 iCpA/IaqBfoga7zMhnrxR58o3g== X-Google-Smtp-Source: AMsMyM4EwitpQWXx4h1DizzorWJlFI3m6U9QB+IVVOYkorBbs+ZJzX5k/nvjVQ4W71r1y55Gw3n5tQ== X-Received: by 2002:a05:600c:6885:b0:3c4:de24:638 with SMTP id fn5-20020a05600c688500b003c4de240638mr26552775wmb.183.1666188145462; Wed, 19 Oct 2022 07:02:25 -0700 (PDT) Received: from localhost.localdomain ([213.146.143.36]) by smtp.gmail.com with ESMTPSA id p39-20020a05600c1da700b003c6d21a19a0sm16501854wms.29.2022.10.19.07.02.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 07:02:25 -0700 (PDT) From: Zhangfei Gao To: Anatoly Burakov , Akhil Goyal , Fan Zhang , David Marchand Cc: dev@dpdk.org, acc@openeuler.org, Zhangfei Gao Subject: [PATCH v2] bus/vdev: vdev_cleanup checks dev->device.driver Date: Wed, 19 Oct 2022 21:56:06 +0800 Message-Id: <20221019135606.1700219-1-zhangfei.gao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221019104847.1699872-1-zhangfei.gao@linaro.org> References: <20221019104847.1699872-1-zhangfei.gao@linaro.org> 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 vdev_probe calls driver->probe and set dev->device.driver, which will be NULL if probe fails. In vdev_cleanup, drv = container_of(dev->device.driver) drv will be !NULL in this case. anc cause drv->remove Segmentation fault. Fixed by checking dev->device.driver before. Log: $ sudo dpdk-test --vdev=crypto_uadk --log-level=6 vdev_probe(): failed to initialize crypto_uadk device EAL: Bus (vdev) probe failed. RTE>>quit Segmentation fault Fixes: 1cab1a40ea9b ("bus: cleanup devices on shutdown") Signed-off-by: Zhangfei Gao --- v2: Suggested by David Marchand 1. Add Fixes 2. "If dev->device.driver != NULL, then drv won't be NULL", so remove it drivers/bus/vdev/vdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c index f5b43f1930..41bc07dde7 100644 --- a/drivers/bus/vdev/vdev.c +++ b/drivers/bus/vdev/vdev.c @@ -577,9 +577,12 @@ vdev_cleanup(void) const struct rte_vdev_driver *drv; int ret = 0; + if (dev->device.driver == NULL) + continue; + drv = container_of(dev->device.driver, const struct rte_vdev_driver, driver); - if (drv == NULL || drv->remove == NULL) + if (drv->remove == NULL) continue; ret = drv->remove(dev); -- 2.38.1