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 DE23CA00C2; Wed, 2 Nov 2022 10:12:56 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7DF9C40693; Wed, 2 Nov 2022 10:12:56 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id CF5E140223 for ; Wed, 2 Nov 2022 10:12:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667380375; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p5epriXJ+N1hNbvNUEg9rUqwbEo/X7t2D+NWmx9WX9w=; b=acrqfWjLWa87EOs1SIzC1LOkjAvs9SFZ9h2MhDh9BOTU9Cc6XGtGihJ9l0Lptn6pabxVmx yeFcTSBvN4WCc2wsH4Bq7zd0UBA42JjLdoQ65IBIUHmiOtvW6eKRYleCEcLTHAma53FbE8 VByWDdYdDmOC3uyTc+ijuciXRCNY0uo= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-554-ahWAZO0tMOS5-bxgacMxSQ-1; Wed, 02 Nov 2022 05:12:51 -0400 X-MC-Unique: ahWAZO0tMOS5-bxgacMxSQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4EB741C0A101; Wed, 2 Nov 2022 09:12:51 +0000 (UTC) Received: from [10.39.208.43] (unknown [10.39.208.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0DDC7140EBF5; Wed, 2 Nov 2022 09:12:49 +0000 (UTC) Message-ID: <68eacb2c-4004-1f43-f14c-702bcec9fe6f@redhat.com> Date: Wed, 2 Nov 2022 10:12:47 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: Re: [PATCH] vdpa/ifc: fix update_datapath error handling To: Taekyung Kim , dev@dpdk.org, Chenbo Xia , Xiao Wang References: <20221018072240.128791-1-kim.tae.kyung@navercorp.com> From: Maxime Coquelin In-Reply-To: <20221018072240.128791-1-kim.tae.kyung@navercorp.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 Hi, On 10/18/22 09:22, Taekyung Kim wrote: > Stop and return the error code if update_datapath fails. > update_datapath prepares resources for the vdpa device. > The driver should not perform any further actions > if update_datapath returns an error. You need to add Fixes tag and Cc stable@dpdk.org, so that it is backported to relevant LTS branches. > > Signed-off-by: Taekyung Kim > --- > drivers/vdpa/ifc/ifcvf_vdpa.c | 20 ++++++++++++++++---- > 1 file changed, 16 insertions(+), 4 deletions(-) > > diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c > index d5ac583589..795967e998 100644 > --- a/drivers/vdpa/ifc/ifcvf_vdpa.c > +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c > @@ -1063,7 +1063,10 @@ ifcvf_dev_config(int vid) > internal = list->internal; > internal->vid = vid; > rte_atomic32_set(&internal->dev_attached, 1); > - update_datapath(internal); > + if (update_datapath(internal) < 0) { > + DRV_LOG(ERR, "failed to update datapath: %p", vdev); > + return -1; > + } > > if (rte_vhost_host_notifier_ctrl(vid, RTE_VHOST_QUEUE_ALL, true) != 0) > DRV_LOG(NOTICE, "vDPA (%s): software relay is used.", > @@ -1105,7 +1108,10 @@ ifcvf_dev_close(int vid) > internal->sw_fallback_running = false; > } else { > rte_atomic32_set(&internal->dev_attached, 0); > - update_datapath(internal); > + if (update_datapath(internal) < 0) { > + DRV_LOG(ERR, "failed to update datapath: %p", vdev); > + return -1; > + } > } > > internal->configured = 0; > @@ -1632,7 +1638,10 @@ ifcvf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, > pthread_mutex_unlock(&internal_list_lock); > > rte_atomic32_set(&internal->started, 1); > - update_datapath(internal); > + if (update_datapath(internal) < 0) { > + DRV_LOG(ERR, "failed to update datapath: %s", pci_dev->name); > + return -1; > + } This is not enough, you need to free resources allocated before, otherwise you introduce memory leaks. Basically, you should goto error instead o directly returning -1. > > rte_kvargs_free(kvlist); > return 0; > @@ -1661,7 +1670,10 @@ ifcvf_pci_remove(struct rte_pci_device *pci_dev) > > internal = list->internal; > rte_atomic32_set(&internal->started, 0); > - update_datapath(internal); > + if (update_datapath(internal) < 0) { > + DRV_LOG(ERR, "failed to update datapath: %s", pci_dev->name); > + return -1; > + } I think we should not return early here, because we still want to clean as much as possible on remove. maybe just keep the error message. > rte_pci_unmap_device(internal->pdev); > rte_vfio_container_destroy(internal->vfio_container_fd); Thanks, Maxime