All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Zheyu Ma <zheyuma97@gmail.com>
Cc: mst <mst@redhat.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	virtualization <virtualization@lists.linux-foundation.org>,
	Yongji Xie <xieyongji@bytedance.com>,
	Zhu Lingshan <lingshan.zhu@intel.com>,
	Eli Cohen <elic@nvidia.com>
Subject: Re: [BUG] vDPA/ifcvf: got a warning when removing the module
Date: Mon, 23 May 2022 12:15:16 +0800	[thread overview]
Message-ID: <CACGkMEvgtzUXw9v=cMN3=Mqm9YTp_2bKmc4--q2+BREvgVdeLg@mail.gmail.com> (raw)
In-Reply-To: <CAMhUBj=5jD5AjyaF8UmMXAZGFnMEgTruFM2KYL3GGZt-ABcHBQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1006 bytes --]

On Sat, May 21, 2022 at 10:27 PM Zheyu Ma <zheyuma97@gmail.com> wrote:
>
> Hello,
>
> I found a bug in the ifcvf driver.
> When removing the module, I got the following warning:
>
> [   14.478123] general protection fault, probably for non-canonical
> address 0xdffffc0000000005: 0000 [#1] PREEMPT SMP KASAN PTI
> [   14.478701] KASAN: null-ptr-deref in range
> [0x0000000000000028-0x000000000000002f]
> [   14.479922] RIP: 0010:vdpa_mgmtdev_unregister+0x39/0x150
> [   14.484063] Call Trace:
> [   14.484186]  <TASK>
> [   14.484292]  ? _raw_spin_unlock_irqrestore+0x3d/0x60
> [   14.484536]  ifcvf_remove+0x3a/0x50 [ifcvf]
> [   14.484743]  pci_device_remove+0x92/0x240
>
> The reason is that the 'ifcvf_mgmt_dev' is zero which means that
> ifcvf_vdpa_dev_add() was not executed.
> Since I am not familiar with the driver, I cannot find a proper solution for it.
>

Looks like the drv data needs to be set in probe(). Could you pleas
try to the attached patch? (compile test only).

Thanks

> Zheyu Ma
>

[-- Attachment #2: 0001-vdpa-ifcvf-set-pci-driver-data-in-probe.patch --]
[-- Type: application/octet-stream, Size: 1265 bytes --]

From c7c031d1a5c64e0f58e01579ff78224a58d6a4fa Mon Sep 17 00:00:00 2001
From: Jason Wang <jasowang@redhat.com>
Date: Mon, 23 May 2022 12:12:00 +0800
Subject: [PATCH] vdpa: ifcvf: set pci driver data in probe
Content-type: text/plain

We should set the pci driver data in probe instead of the vdpa device
adding callback. Otherwise if no vDPA device is created we will lose
the pointer to the management device.

Fixes: 6b5df347c6482 ("vDPA/ifcvf: implement management netlink framework for ifcvf")
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 drivers/vdpa/ifcvf/ifcvf_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c b/drivers/vdpa/ifcvf/ifcvf_main.c
index 4366320fb68d..197d52e7b801 100644
--- a/drivers/vdpa/ifcvf/ifcvf_main.c
+++ b/drivers/vdpa/ifcvf/ifcvf_main.c
@@ -765,7 +765,6 @@ static int ifcvf_vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name,
 	}
 
 	ifcvf_mgmt_dev->adapter = adapter;
-	pci_set_drvdata(pdev, ifcvf_mgmt_dev);
 
 	vf = &adapter->vf;
 	vf->dev_type = get_dev_type(pdev);
@@ -880,6 +879,8 @@ static int ifcvf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 		goto err;
 	}
 
+	pci_set_drvdata(pdev, ifcvf_mgmt_dev);
+
 	return 0;
 
 err:
-- 
2.25.1


[-- Attachment #3: Type: text/plain, Size: 183 bytes --]

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

WARNING: multiple messages have this Message-ID (diff)
From: Jason Wang <jasowang@redhat.com>
To: Zheyu Ma <zheyuma97@gmail.com>
Cc: mst <mst@redhat.com>, Zhu Lingshan <lingshan.zhu@intel.com>,
	Yongji Xie <xieyongji@bytedance.com>, Eli Cohen <elic@nvidia.com>,
	Parav Pandit <parav@nvidia.com>,
	virtualization <virtualization@lists.linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [BUG] vDPA/ifcvf: got a warning when removing the module
Date: Mon, 23 May 2022 12:15:16 +0800	[thread overview]
Message-ID: <CACGkMEvgtzUXw9v=cMN3=Mqm9YTp_2bKmc4--q2+BREvgVdeLg@mail.gmail.com> (raw)
In-Reply-To: <CAMhUBj=5jD5AjyaF8UmMXAZGFnMEgTruFM2KYL3GGZt-ABcHBQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1006 bytes --]

On Sat, May 21, 2022 at 10:27 PM Zheyu Ma <zheyuma97@gmail.com> wrote:
>
> Hello,
>
> I found a bug in the ifcvf driver.
> When removing the module, I got the following warning:
>
> [   14.478123] general protection fault, probably for non-canonical
> address 0xdffffc0000000005: 0000 [#1] PREEMPT SMP KASAN PTI
> [   14.478701] KASAN: null-ptr-deref in range
> [0x0000000000000028-0x000000000000002f]
> [   14.479922] RIP: 0010:vdpa_mgmtdev_unregister+0x39/0x150
> [   14.484063] Call Trace:
> [   14.484186]  <TASK>
> [   14.484292]  ? _raw_spin_unlock_irqrestore+0x3d/0x60
> [   14.484536]  ifcvf_remove+0x3a/0x50 [ifcvf]
> [   14.484743]  pci_device_remove+0x92/0x240
>
> The reason is that the 'ifcvf_mgmt_dev' is zero which means that
> ifcvf_vdpa_dev_add() was not executed.
> Since I am not familiar with the driver, I cannot find a proper solution for it.
>

Looks like the drv data needs to be set in probe(). Could you pleas
try to the attached patch? (compile test only).

Thanks

> Zheyu Ma
>

[-- Attachment #2: 0001-vdpa-ifcvf-set-pci-driver-data-in-probe.patch --]
[-- Type: application/octet-stream, Size: 1265 bytes --]

From c7c031d1a5c64e0f58e01579ff78224a58d6a4fa Mon Sep 17 00:00:00 2001
From: Jason Wang <jasowang@redhat.com>
Date: Mon, 23 May 2022 12:12:00 +0800
Subject: [PATCH] vdpa: ifcvf: set pci driver data in probe
Content-type: text/plain

We should set the pci driver data in probe instead of the vdpa device
adding callback. Otherwise if no vDPA device is created we will lose
the pointer to the management device.

Fixes: 6b5df347c6482 ("vDPA/ifcvf: implement management netlink framework for ifcvf")
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 drivers/vdpa/ifcvf/ifcvf_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c b/drivers/vdpa/ifcvf/ifcvf_main.c
index 4366320fb68d..197d52e7b801 100644
--- a/drivers/vdpa/ifcvf/ifcvf_main.c
+++ b/drivers/vdpa/ifcvf/ifcvf_main.c
@@ -765,7 +765,6 @@ static int ifcvf_vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name,
 	}
 
 	ifcvf_mgmt_dev->adapter = adapter;
-	pci_set_drvdata(pdev, ifcvf_mgmt_dev);
 
 	vf = &adapter->vf;
 	vf->dev_type = get_dev_type(pdev);
@@ -880,6 +879,8 @@ static int ifcvf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 		goto err;
 	}
 
+	pci_set_drvdata(pdev, ifcvf_mgmt_dev);
+
 	return 0;
 
 err:
-- 
2.25.1


  reply	other threads:[~2022-05-23  4:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-21 14:27 [BUG] vDPA/ifcvf: got a warning when removing the module Zheyu Ma
2022-05-23  4:15 ` Jason Wang [this message]
2022-05-23  4:15   ` Jason Wang
2022-05-23  4:47   ` Zheyu Ma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CACGkMEvgtzUXw9v=cMN3=Mqm9YTp_2bKmc4--q2+BREvgVdeLg@mail.gmail.com' \
    --to=jasowang@redhat.com \
    --cc=elic@nvidia.com \
    --cc=lingshan.zhu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=xieyongji@bytedance.com \
    --cc=zheyuma97@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.