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 CC804A06C8; Wed, 19 Oct 2022 16:14:20 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AF3AC42B6C; Wed, 19 Oct 2022 16:14:20 +0200 (CEST) Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by mails.dpdk.org (Postfix) with ESMTP id B2FF3410D1 for ; Wed, 19 Oct 2022 16:14:18 +0200 (CEST) Received: by mail-wm1-f52.google.com with SMTP id iv17so13025091wmb.4 for ; Wed, 19 Oct 2022 07:14:18 -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=hj1EPG3PSvqIX1XQQXAVASUgIXm8CXIe84sXSjf/uiI=; b=VQmmuCyoJ8T7XIF1Fu2EkH4nap0wx4mF1LEbGO1cXf1rEE90d9ZAIBb8bU51H06/SF xGLm8A0364pBsr09I0BhamCuYwjVrVgyoglJhipEqaxGhuqxOqfqLMT84Z+sBXqKe8QG fbzCBac5G2hL8DfimVQEOFBJr34aWIndwCrwzOyd4YbAvWj8xtq5aieWZUSaVy3TZFLK gMn0n3MESy7H/UAdLwzABE8to+1ohkQNOxw/0oz48FmSByL9LNn7mvMAJd7HBAgMWR2Z D7VITGGv4DGHO1rCsj5MBDf1OoyAL9JiyiCx0nBH9QqIECfJh2Y19WdLstwQXkhvDO6F +sig== 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=hj1EPG3PSvqIX1XQQXAVASUgIXm8CXIe84sXSjf/uiI=; b=YmGRG3uzKEDYx7rmj0nOrqHbLQU3rlCmrBTxlD6LZWEoBlNdCJPpIVwaiNyBjWN1hZ vWJ0biEFdTNmcNuKeB5j2tk7pxFCrePnLh5iNmkakApco4ocRiw/aZWsI90oE0sZzePk dgCWa36DelrWspOYzKLsesQwvBjg8zKwhpPcWcwkaBjTLX9YfRH+EW08LMpA19VGcPLd 0uDK+i3xWl7mTj32XgvuDTxN5BZsJE7quJd2ue0E15RwNt3BCzkR8p2aHgblhg/qpSyB G5kO9E+aQScXJDljAHiuf0JWppWt7PMxN8XWnIBtl/6nJd3hK565k5jW9Rb0ZVnAfKaW 0EdA== X-Gm-Message-State: ACrzQf1kekA1xupiLtATAfLPEEuem/cXWrL8q8MlcNUCTcUKwMWcVyoI jI6mjs3M8XCVRs//BDdmNwTgLw== X-Google-Smtp-Source: AMsMyM4hzR5NxXKf6zz6V8kegCym1vxtDQMM2y0KFo50DwjILT6LQkwTe/8wa6g5TWuejJwsf9fhGg== X-Received: by 2002:a05:600c:3844:b0:3b4:becc:e43 with SMTP id s4-20020a05600c384400b003b4becc0e43mr26905211wmr.33.1666188858488; Wed, 19 Oct 2022 07:14:18 -0700 (PDT) Received: from localhost.localdomain ([213.146.143.36]) by smtp.gmail.com with ESMTPSA id r12-20020adff10c000000b00225239d9265sm14046267wro.74.2022.10.19.07.14.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 07:14:17 -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 resend] bus/vdev: vdev_cleanup checks dev->device.driver Date: Wed, 19 Oct 2022 22:08:01 +0800 Message-Id: <20221019140801.1700392-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 the probe fails. In vdev_cleanup, drv = container_of(dev->device.driver) drv will be !NULL in this case, causing 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