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 142AAA0586; Wed, 19 Oct 2022 15:37:48 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A02EB427F3; Wed, 19 Oct 2022 15:37:47 +0200 (CEST) Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) by mails.dpdk.org (Postfix) with ESMTP id BA3B0410D1 for ; Wed, 19 Oct 2022 15:37:46 +0200 (CEST) Received: by mail-ej1-f44.google.com with SMTP id ot12so40097580ejb.1 for ; Wed, 19 Oct 2022 06:37:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=PTQnXx/cvUHhOW+nhP/MrMLZWtmdHyeyDMrqwzhYzcI=; b=PkqFrhRGJ/4vbeZ9LUceSskCRm3w+BZXwcbkOliVoLjyorJfAiOhm3J5VUYgbWhh/p Ow6rPUWHJXjtnNrmehyp2xM3Wk9tHr+AdW79qMcq1tpbbVmezeK2YZmuyQBk9BdIF1bZ V+m2YSVAnnNJxT3iCDUAHubrCWhp7fp6R3TXeZKsKjxV/P269Ez5AF2gmU4GRazGin6P 33FrAhUDTHsMqqCGz4hQ5qxq9/AT7LN2DQFRUswHtpdH4CAqT2BWhdaM847yvraqj/Np bjS79r28tvO7JuDgpqmiGEGgz4SLTG6gMvsieYnfHNopTKnIGaBJkaQCrOjDl6n5Ut6j MUNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PTQnXx/cvUHhOW+nhP/MrMLZWtmdHyeyDMrqwzhYzcI=; b=SIuSaZvfN9QkB3uO7HzDTokjxdbzP6KacId0n2LY8TkVaS+D4tOiWVjP4ZPKcvOBm2 W1rXP90cIOaX09YK9g+cWhvM+RoVEF9+GOKRE43mD3LB0K7TJq94PT/PZnFCA3LpZAye 7gE9Um3GWmiQU+4o5aTIwKDVpZV/qH7a2nTaaawMd9/Lfxa6DRmhXwPxOdLtgtmGbeLg OaS4B58xQcyAns1NyTWTzj5MvBwEzWSSfeIe7sc1RgyjS2taFOF1nAk6Wry4a/i3ETWs wO3+lG9g3qp/CgwUzfDTvG5NADigi2xMPxEvt4xKEgA7NsrQM5yBqdmDQebjHTQk5g9a ryJQ== X-Gm-Message-State: ACrzQf1y25X2cKw9ZkQrG1UXwmCYRibvyijdtE8obTtbbsDYjk4R+S3L +CHuGyUkOlzTCe5SENkEsItn3hiObK1qP4muEwyO59WKItTWsllg X-Google-Smtp-Source: AMsMyM4kZu1rpKq+4ZzJCxtoDdvqfNBhdtMOJdezTP14J2XSpKhjNAlW9rWXj/VzeewHRn8XBw+s0IAggc0JXp5Ikjk= X-Received: by 2002:a17:906:ee88:b0:78d:1a9a:b2db with SMTP id wt8-20020a170906ee8800b0078d1a9ab2dbmr6607076ejb.225.1666186666425; Wed, 19 Oct 2022 06:37:46 -0700 (PDT) MIME-Version: 1.0 References: <20221019104847.1699872-1-zhangfei.gao@linaro.org> In-Reply-To: From: Zhangfei Gao Date: Wed, 19 Oct 2022 21:37:34 +0800 Message-ID: Subject: Re: [PATCH] bus/vdev: vdev_cleanup checks dev->device.driver To: David Marchand Cc: Anatoly Burakov , Akhil Goyal , Fan Zhang , dev@dpdk.org, acc@openeuler.org Content-Type: text/plain; charset="UTF-8" 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 On Wed, 19 Oct 2022 at 19:39, David Marchand wrote: > > On Wed, Oct 19, 2022 at 12:55 PM Zhangfei Gao wrote: > > > > 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 () > > I suspect you hit this issue when running some crypto autotest. > Can you confirm? > > > The commit that introduced the issue should be mentionned, with a > Fixes: tag, like: > Fixes: 1cab1a40ea9b ("bus: cleanup devices on shutdown") > > > > > 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) > > If dev->device.driver != NULL, then drv won't be NULL. Sorry, I miss this, add log to be clear $ sudo dpdk-test --vdev=crypto_uadk --log-level=6 vdev_probe_all_drivers dev->device.driver=(nil) ret=-19 vdev_probe(): failed to initialize crypto_uadk device EAL: Bus (vdev) probe failed. TELEMETRY: No legacy callbacks, legacy socket not created RTE>>quit vdev_cleanup dev->device.driver=(nil) vdev_cleanup drv=0xfffffffffffffff0 Segmentation fault > > > -- > David Marchand >