Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4412501rdb; Fri, 15 Sep 2023 01:00:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH90dnbGBaY7pLYu1pHoT38Wwy1KyczZNhJmZgfg1sySCqkwa5iDu3gPm2/pxNI0Ws+4CpA X-Received: by 2002:a17:90a:f3d4:b0:26d:54de:b0d6 with SMTP id ha20-20020a17090af3d400b0026d54deb0d6mr667595pjb.20.1694764843926; Fri, 15 Sep 2023 01:00:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694764843; cv=none; d=google.com; s=arc-20160816; b=ujuLAVZ6RPmc/bLw5HICva/z6snkPiIerpvdV84xZsWFR2sAHFaPmoZ43dGi1aCBMl Y9yAACTvuLuy8rsrFQis6yKaE5fiyYwH9A3I+uy6eEoW9dwnu3VfH5gadY6MmfoDkzOz RJUScbW5aCrK/8kgpW/kwCcA+h6dmdUPZLw4NfCNbr89Elu5mDZHKblpIdKDULtCQFJB QDq/hl9YxH5qPqx5ETIT1OJULwO+dofEgy4/YAzEyqp4HMrM4BTZgcbIXVpJqi+cwq8W Uhn5J6uQeosFEMijI24kPrp8ORK1FBQMbwtazrEaIn797O/WWlKAbvgx9qfNx6X/S5Hw dUSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=1yo/ltbu6gyQyMT5IUFnw0353h8EE843EVbYpVcgDCY=; fh=h0Bj/5NgSZCkUqPxcfpvnWabg1htxcTemysZ+btjReE=; b=b6Wn1ylq34hiK8+ENlrod5yeppMcVWkIW98tVZcTjAuAAMCkgWsr3Qb6mlrHpj4ADb ytj8eNY679SJQzduS3cRyxrwYVbrvzR7C7KDlehQYHrJwJ9I1KXx5o17Pb6gSdMoy36K PaJ0Drx95Uh+GhMnN7Rlx2ha/mR1nWxz2wvJB48nUdjNRMsXk7C5iI7lNalE6JgNyir8 nTzGwgmgq7MDtScORVKO+1rYoEmeKv/llyhAEeNwqYem3f2ab3BecPyTVUs2k101+vbn fBkxtBEWOxckAlVes/hB3lqXz+d2fT7A3wApDtNYiisANPnu11xMFcRFA3+M784wWAGm lWVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fOfXgseb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id b24-20020a17090ae39800b002689d34ae8dsi5089143pjz.18.2023.09.15.01.00.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 01:00:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fOfXgseb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 3F1EF8377254; Thu, 14 Sep 2023 23:54:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232500AbjIOGyr (ORCPT + 99 others); Fri, 15 Sep 2023 02:54:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230109AbjIOGyo (ORCPT ); Fri, 15 Sep 2023 02:54:44 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7EAE1271B for ; Thu, 14 Sep 2023 23:53:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694760831; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1yo/ltbu6gyQyMT5IUFnw0353h8EE843EVbYpVcgDCY=; b=fOfXgsebTK24AKu48VUFmPQaBhoEL2/paJzt4YQFC4rePPYNqgzrpQH5YhiiF7ifXDhUg5 ahuLpicKzwKKgvDrQEazRGc9ZlcNIL6ZjXaYn48yT9PY3Qn221/QvYIMuZvNpoE8bJV14W Mjyx7NsQ7KCcHXbhPkq1qnkibETjLX4= Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-7-33B9WMTWPjmwKj1D5zy3Lg-1; Fri, 15 Sep 2023 02:53:48 -0400 X-MC-Unique: 33B9WMTWPjmwKj1D5zy3Lg-1 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-500c67585acso2096529e87.2 for ; Thu, 14 Sep 2023 23:53:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694760827; x=1695365627; h=content-transfer-encoding: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=1yo/ltbu6gyQyMT5IUFnw0353h8EE843EVbYpVcgDCY=; b=TY/WHiKu8KQV/Lb7F1IhWveeAKF+UtKlwyZcNUqAzlMeKBB0o+XEX8k48GDQ8dxw0z wfptYrnQQn2aqg8DDWzVQ+xrhVZn6nahik/PGYUcO+iEKYyHdUNsuxLPgH3EwJIQdtT2 ORj7mWeGtn89DFEzpgYEEv8BAG47SLtgTMKcy7Rx56ypyy5ggv3+yZcL+azeeb/7e62b trOxaD6ZdPkHjsgMcJujHgx+39IKdgoIU95Nv8L9lGuT8xutwrSre0hJvx5fu9wY/D3n CwC+x1VGVgRk/AeEML5KuJOD5sONRDAaqjGPBfh7iBR0gdmlfxTyiBJa0diBuuAFDj2O RWaA== X-Gm-Message-State: AOJu0YwA+z+/0jGnoO7dMgwTrq9srbTRD3Kqva+NCWzEes9HrsE+kYwL AwV2pvMNRNLxCAd+7Z5vC8GQeaE8IYskOQFCQgph+080Os3AUlE/6Awg60w/RGYTubx7BsHt5Ev gw/ASqIKqDU0Pie2SUQ+KZ9RxJKPvs28qsJQK/aoq X-Received: by 2002:a05:6512:2118:b0:4fb:bef0:948e with SMTP id q24-20020a056512211800b004fbbef0948emr756377lfr.5.1694760826848; Thu, 14 Sep 2023 23:53:46 -0700 (PDT) X-Received: by 2002:a05:6512:2118:b0:4fb:bef0:948e with SMTP id q24-20020a056512211800b004fbbef0948emr756367lfr.5.1694760826555; Thu, 14 Sep 2023 23:53:46 -0700 (PDT) MIME-Version: 1.0 References: <20230829174014.928189-2-dtatulea@nvidia.com> In-Reply-To: <20230829174014.928189-2-dtatulea@nvidia.com> From: Jason Wang Date: Fri, 15 Sep 2023 14:53:35 +0800 Message-ID: Subject: Re: [PATCH] vdpa/mlx5: Fix double release of debugfs entry To: Dragos Tatulea Cc: "Michael S. Tsirkin" , Xuan Zhuo , Gal Pressman , virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 14 Sep 2023 23:54:52 -0700 (PDT) On Wed, Aug 30, 2023 at 1:40=E2=80=AFAM Dragos Tatulea wrote: > > The error path in setup_driver deletes the debugfs entry but doesn't > clear the pointer. During .dev_del the invalid pointer will be released > again causing a crash. > > This patch fixes the issue by always clearing the debugfs entry in > mlx5_vdpa_remove_debugfs. Also, stop removing the debugfs entry in > .dev_del op: the debugfs entry is already handled within the > setup_driver/teardown_driver scope. > > Fixes: f0417e72add5 ("vdpa/mlx5: Add and remove debugfs in setup/teardown= driver") > Signed-off-by: Dragos Tatulea > Reviewed-by: Gal Pressman Acked-by: Jason Wang Thanks > --- > drivers/vdpa/mlx5/net/debug.c | 5 +++-- > drivers/vdpa/mlx5/net/mlx5_vnet.c | 7 ++----- > drivers/vdpa/mlx5/net/mlx5_vnet.h | 2 +- > 3 files changed, 6 insertions(+), 8 deletions(-) > > diff --git a/drivers/vdpa/mlx5/net/debug.c b/drivers/vdpa/mlx5/net/debug.= c > index 60d6ac68cdc4..9c85162c19fc 100644 > --- a/drivers/vdpa/mlx5/net/debug.c > +++ b/drivers/vdpa/mlx5/net/debug.c > @@ -146,7 +146,8 @@ void mlx5_vdpa_add_debugfs(struct mlx5_vdpa_net *ndev= ) > ndev->rx_dent =3D debugfs_create_dir("rx", ndev->debugfs)= ; > } > > -void mlx5_vdpa_remove_debugfs(struct dentry *dbg) > +void mlx5_vdpa_remove_debugfs(struct mlx5_vdpa_net *ndev) > { > - debugfs_remove_recursive(dbg); > + debugfs_remove_recursive(ndev->debugfs); > + ndev->debugfs =3D NULL; > } > diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/ml= x5_vnet.c > index 37be945a0230..f91c938b4be1 100644 > --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c > +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c > @@ -2713,7 +2713,7 @@ static int setup_driver(struct mlx5_vdpa_dev *mvdev= ) > err_rqt: > teardown_virtqueues(ndev); > err_setup: > - mlx5_vdpa_remove_debugfs(ndev->debugfs); > + mlx5_vdpa_remove_debugfs(ndev); > out: > return err; > } > @@ -2727,8 +2727,7 @@ static void teardown_driver(struct mlx5_vdpa_net *n= dev) > if (!ndev->setup) > return; > > - mlx5_vdpa_remove_debugfs(ndev->debugfs); > - ndev->debugfs =3D NULL; > + mlx5_vdpa_remove_debugfs(ndev); > teardown_steering(ndev); > destroy_tir(ndev); > destroy_rqt(ndev); > @@ -3489,8 +3488,6 @@ static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev = *v_mdev, struct vdpa_device * > struct mlx5_vdpa_net *ndev =3D to_mlx5_vdpa_ndev(mvdev); > struct workqueue_struct *wq; > > - mlx5_vdpa_remove_debugfs(ndev->debugfs); > - ndev->debugfs =3D NULL; > unregister_link_notifier(ndev); > _vdpa_unregister_device(dev); > wq =3D mvdev->wq; > diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.h b/drivers/vdpa/mlx5/net/ml= x5_vnet.h > index 36c44d9fdd16..60cdbc903037 100644 > --- a/drivers/vdpa/mlx5/net/mlx5_vnet.h > +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.h > @@ -88,7 +88,7 @@ struct macvlan_node { > }; > > void mlx5_vdpa_add_debugfs(struct mlx5_vdpa_net *ndev); > -void mlx5_vdpa_remove_debugfs(struct dentry *dbg); > +void mlx5_vdpa_remove_debugfs(struct mlx5_vdpa_net *ndev); > void mlx5_vdpa_add_rx_flow_table(struct mlx5_vdpa_net *ndev); > void mlx5_vdpa_remove_rx_flow_table(struct mlx5_vdpa_net *ndev); > void mlx5_vdpa_add_tirn(struct mlx5_vdpa_net *ndev); > -- > 2.41.0 >