From patchwork Wed Oct 19 10:48:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 616429 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp199781pvb; Wed, 19 Oct 2022 03:55:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6klFg8jTcDSJ2BPiBbvX1zjXS3KxL9GUY5l5gtU2P2Ly8UgAJH/wu2guxwW0z5HlqVGKx6 X-Received: by 2002:a50:fb0f:0:b0:458:df03:c3aa with SMTP id d15-20020a50fb0f000000b00458df03c3aamr6690004edq.83.1666176904660; Wed, 19 Oct 2022 03:55:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666176904; cv=none; d=google.com; s=arc-20160816; b=btFalj15huRsVvIzd7COg3K0w0z2TiUOSoTKrhxh5zICEhfP/b0bw3PG0pC2f8ucAf c5s/ynLPM8DhUFYF99m1kFh5b9wJz8Lq7UX6qLjVvXwYNYnCkFsnFn8Roc6XYPHqZ0ZO HUN35VbrpYlKwmiN8MIv2dRK/R2JrlujkuK5HKHH4vOKDXac8Zf95JNJTI4Rogz2tzob R0F3K0q3baAwCMfBNNmFxP4a3ehKobhWRREIdsshjlOZ7tMlbmUke7pP4wcukllgNrXW JyMjJIRNiBJyRvB6vt4n7TAA4uhxZTkmHwAgaS9lbgxVfE2zBWJVbzpD6ugtFP8M3LPc 0QNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=nnYH1d+ibJ/+g49OjbeLGS80i8Z+00yZMzE0Bcgrjh0=; b=gwEnYZle3f7iLuQtmq262vGJ+4xcYfeciocnJpS4BJHO5u3WdjOCOSZHeFLJ/w5Cpb LSLAtnrBMFDqjqqYVeKbBU+OblAIRT1RJhmYLYqfhkcoRcvGUKAlqv790kI1v6gQgaWU abGI6iobz21PaM1Yf0eRtgjqWhVqr0nZ2K+ApzlQujLL42qL2HEsbDKe5JMej9aROjjv 7Hwk/mGLQHaV34MGhh1h0Rkv9pqSZH0wLekPsFZLM6Wq4f5j4bqbsho2DDpZzpzh7Tuj GakUqu1lBaPkeW6EjG1eFQQss7RY0fYeWBlcN5N3H9Yti+Xmfc4dL6m1xG8epZoSu6NR 5Zuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ch/uYqko"; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mails.dpdk.org (mails.dpdk.org. [217.70.189.124]) by mx.google.com with ESMTP id g11-20020a056402090b00b00457053aadeasi17149260edz.398.2022.10.19.03.55.04; Wed, 19 Oct 2022 03:55:04 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) client-ip=217.70.189.124; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ch/uYqko"; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4C30E410D1; Wed, 19 Oct 2022 12:55:04 +0200 (CEST) Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by mails.dpdk.org (Postfix) with ESMTP id EA2EB40E03 for ; Wed, 19 Oct 2022 12:55:02 +0200 (CEST) Received: by mail-wm1-f44.google.com with SMTP id 186-20020a1c02c3000000b003c6c154d528so2525133wmc.4 for ; Wed, 19 Oct 2022 03:55:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=nnYH1d+ibJ/+g49OjbeLGS80i8Z+00yZMzE0Bcgrjh0=; b=ch/uYqkonqblEZAgw4Wqtospa1+AOB82z/lcHNNzKyN4p/cG5xMeXCq3O90saCJ/hD GBnxHVjrAd68kVM5QvmIy2WwZ9epMwNmfnOVokDKIOKIVgZL6Q62r0KBHXjEf3a17OKZ fbYURk7r3wfkMyIVYSwXXozaLX7KUjfvfaSXwxms1B6Ye0H+bAypcJdl9TX3+EaOGNiX Z7WKe7irg8ILPnHcGTVEVIXGBaPX7GvenSsDO0WN4cTECLyrdUlk94WRjaz8nU8hgkK/ ThjBCqy+AV9DfZHyPPTPJFGEf+yLzQaVQKjoxlK3fVJm93a8zrskuCmTtIVtuUB6g3fA UbZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=nnYH1d+ibJ/+g49OjbeLGS80i8Z+00yZMzE0Bcgrjh0=; b=D22txkhewy6H/KeDeGyCexS2txr5m7QoZL7IBPPhrGqZJm3ec7YORIbqNyoYGQi/cW ACaATolhls/BjN8+/spW/7Yy+f1jcDaExqPCt+qDjvj712TGoI5rUNyBcrBoaqhrBamd 5cSGBZG7XJZ/362N0mifiVZcyGePthsX2ou48xrZ5UK3aNdCfJwfKeHUiqP9ewP5o92Y xWao61rvBpVeNHDBwTPpu9yLXKKG+D+wVWDa4UbPaClD4OY5b4aN3cWOklRuwLoX5mck vb1vH0iY2Bsp7/ghDSy27VOmiGv4KBqGVmqo8ObUWd7gei4MZb2wdy75MBrmRvM/dp8i vstg== X-Gm-Message-State: ACrzQf0n9zXjywGLngmZsE+S/4DWXnEmS2de0PpDpaLcJOBeDVxedn/o FnFmV/rL8FCF1UWBNHHGB2w6Pg== X-Received: by 2002:a7b:c5c2:0:b0:3c4:fd96:fb68 with SMTP id n2-20020a7bc5c2000000b003c4fd96fb68mr5089424wmk.36.1666176902724; Wed, 19 Oct 2022 03:55:02 -0700 (PDT) Received: from localhost.localdomain ([213.146.143.36]) by smtp.gmail.com with ESMTPSA id z11-20020a05600c0a0b00b003c6bd91caa5sm18154096wmp.17.2022.10.19.03.55.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 03:55:02 -0700 (PDT) From: Zhangfei Gao To: Anatoly Burakov , Akhil Goyal , Fan Zhang Cc: dev@dpdk.org, acc@openeuler.org, Zhangfei Gao Subject: [PATCH] bus/vdev: vdev_cleanup checks dev->device.driver Date: Wed, 19 Oct 2022 18:48:47 +0800 Message-Id: <20221019104847.1699872-1-zhangfei.gao@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 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 The vdev_probe calls driver->probe, which may fail and dev->device.driver will still be NULL. In vdev_cleanup, drv = container_of(dev->device.driver) returns !NULL, then drv->remove will trigger Segmentation fault. Fix it by checking dev->device.driver first. Log: Thread 1 "dpdk-test" received signal SIGSEGV, Segmentation fault. 0x00000000012c484d in vdev_cleanup () Signed-off-by: Zhangfei Gao --- drivers/bus/vdev/vdev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c index f5b43f1930..fbdaf68380 100644 --- a/drivers/bus/vdev/vdev.c +++ b/drivers/bus/vdev/vdev.c @@ -577,6 +577,9 @@ 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)