linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vboxguest: add missing devm_free_irq
@ 2022-06-09 13:40 Pascal Terjan
  2022-06-10 13:50 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 6+ messages in thread
From: Pascal Terjan @ 2022-06-09 13:40 UTC (permalink / raw)
  To: Hans de Goede, Arnd Bergmann, Greg Kroah-Hartman
  Cc: linux-kernel, Pascal Terjan

This fixes the following warning when unloading the module:

[249348.837181] remove_proc_entry: removing non-empty directory 'irq/20', leaking at least 'vboxguest'
[249348.837219] WARNING: CPU: 0 PID: 6708 at fs/proc/generic.c:715 remove_proc_entry+0x119/0x140

[249348.837379] Call Trace:
[249348.837385]  unregister_irq_proc+0xbd/0xe0
[249348.837392]  free_desc+0x23/0x60
[249348.837396]  irq_free_descs+0x4a/0x70
[249348.837401]  irq_domain_free_irqs+0x160/0x1a0
[249348.837452]  mp_unmap_irq+0x5c/0x60
[249348.837458]  acpi_unregister_gsi_ioapic+0x29/0x40
[249348.837463]  acpi_unregister_gsi+0x17/0x30
[249348.837467]  acpi_pci_irq_disable+0xbf/0xe0
[249348.837473]  pcibios_disable_device+0x20/0x30
[249348.837478]  pci_disable_device+0xef/0x120
[249348.837482]  vbg_pci_remove+0x6c/0x70 [vboxguest]

Signed-off-by: Pascal Terjan <pterjan@google.com>
---
 drivers/virt/vboxguest/vboxguest_linux.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/virt/vboxguest/vboxguest_linux.c b/drivers/virt/vboxguest/vboxguest_linux.c
index 6e8c0f1c1056..faa4bc9f625c 100644
--- a/drivers/virt/vboxguest/vboxguest_linux.c
+++ b/drivers/virt/vboxguest/vboxguest_linux.c
@@ -423,6 +423,7 @@ static void vbg_pci_remove(struct pci_dev *pci)
 	vbg_gdev = NULL;
 	mutex_unlock(&vbg_gdev_mutex);
 
+	devm_free_irq(gdev->dev, pci->irq, gdev);
 	device_remove_file(gdev->dev, &dev_attr_host_features);
 	device_remove_file(gdev->dev, &dev_attr_host_version);
 	misc_deregister(&gdev->misc_device_user);
-- 
2.36.1.476.g0c4daa206d-goog


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] vboxguest: add missing devm_free_irq
  2022-06-09 13:40 [PATCH] vboxguest: add missing devm_free_irq Pascal Terjan
@ 2022-06-10 13:50 ` Greg Kroah-Hartman
  2022-06-10 15:00   ` Pascal Terjan
  0 siblings, 1 reply; 6+ messages in thread
From: Greg Kroah-Hartman @ 2022-06-10 13:50 UTC (permalink / raw)
  To: Pascal Terjan; +Cc: Hans de Goede, Arnd Bergmann, linux-kernel

On Thu, Jun 09, 2022 at 02:40:57PM +0100, Pascal Terjan wrote:
> This fixes the following warning when unloading the module:
> 
> [249348.837181] remove_proc_entry: removing non-empty directory 'irq/20', leaking at least 'vboxguest'
> [249348.837219] WARNING: CPU: 0 PID: 6708 at fs/proc/generic.c:715 remove_proc_entry+0x119/0x140
> 
> [249348.837379] Call Trace:
> [249348.837385]  unregister_irq_proc+0xbd/0xe0
> [249348.837392]  free_desc+0x23/0x60
> [249348.837396]  irq_free_descs+0x4a/0x70
> [249348.837401]  irq_domain_free_irqs+0x160/0x1a0
> [249348.837452]  mp_unmap_irq+0x5c/0x60
> [249348.837458]  acpi_unregister_gsi_ioapic+0x29/0x40
> [249348.837463]  acpi_unregister_gsi+0x17/0x30
> [249348.837467]  acpi_pci_irq_disable+0xbf/0xe0
> [249348.837473]  pcibios_disable_device+0x20/0x30
> [249348.837478]  pci_disable_device+0xef/0x120
> [249348.837482]  vbg_pci_remove+0x6c/0x70 [vboxguest]
> 
> Signed-off-by: Pascal Terjan <pterjan@google.com>
> ---
>  drivers/virt/vboxguest/vboxguest_linux.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/virt/vboxguest/vboxguest_linux.c b/drivers/virt/vboxguest/vboxguest_linux.c
> index 6e8c0f1c1056..faa4bc9f625c 100644
> --- a/drivers/virt/vboxguest/vboxguest_linux.c
> +++ b/drivers/virt/vboxguest/vboxguest_linux.c
> @@ -423,6 +423,7 @@ static void vbg_pci_remove(struct pci_dev *pci)
>  	vbg_gdev = NULL;
>  	mutex_unlock(&vbg_gdev_mutex);
>  
> +	devm_free_irq(gdev->dev, pci->irq, gdev);

The whope point of using devm_* calls is so you don't have to do stuff
like this.  Perhaps this should not be using devm_() for the irq at all?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] vboxguest: add missing devm_free_irq
  2022-06-10 13:50 ` Greg Kroah-Hartman
@ 2022-06-10 15:00   ` Pascal Terjan
  2022-06-10 16:02     ` Hans de Goede
  0 siblings, 1 reply; 6+ messages in thread
From: Pascal Terjan @ 2022-06-10 15:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Hans de Goede, Arnd Bergmann, linux-kernel

On Fri, 10 Jun 2022 at 13:50, Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> On Thu, Jun 09, 2022 at 02:40:57PM +0100, Pascal Terjan wrote:
> > This fixes the following warning when unloading the module:
> >
> > [249348.837181] remove_proc_entry: removing non-empty directory 'irq/20', leaking at least 'vboxguest'
> > [249348.837219] WARNING: CPU: 0 PID: 6708 at fs/proc/generic.c:715 remove_proc_entry+0x119/0x140
> >
> > [249348.837379] Call Trace:
> > [249348.837385]  unregister_irq_proc+0xbd/0xe0
> > [249348.837392]  free_desc+0x23/0x60
> > [249348.837396]  irq_free_descs+0x4a/0x70
> > [249348.837401]  irq_domain_free_irqs+0x160/0x1a0
> > [249348.837452]  mp_unmap_irq+0x5c/0x60
> > [249348.837458]  acpi_unregister_gsi_ioapic+0x29/0x40
> > [249348.837463]  acpi_unregister_gsi+0x17/0x30
> > [249348.837467]  acpi_pci_irq_disable+0xbf/0xe0
> > [249348.837473]  pcibios_disable_device+0x20/0x30
> > [249348.837478]  pci_disable_device+0xef/0x120
> > [249348.837482]  vbg_pci_remove+0x6c/0x70 [vboxguest]
> >
> > Signed-off-by: Pascal Terjan <pterjan@google.com>
> > ---
> >  drivers/virt/vboxguest/vboxguest_linux.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/virt/vboxguest/vboxguest_linux.c b/drivers/virt/vboxguest/vboxguest_linux.c
> > index 6e8c0f1c1056..faa4bc9f625c 100644
> > --- a/drivers/virt/vboxguest/vboxguest_linux.c
> > +++ b/drivers/virt/vboxguest/vboxguest_linux.c
> > @@ -423,6 +423,7 @@ static void vbg_pci_remove(struct pci_dev *pci)
> >       vbg_gdev = NULL;
> >       mutex_unlock(&vbg_gdev_mutex);
> >
> > +     devm_free_irq(gdev->dev, pci->irq, gdev);
>
> The whope point of using devm_* calls is so you don't have to do stuff
> like this.  Perhaps this should not be using devm_() for the irq at all?

My initial assumption was that some sort of dependency was missing
somewhere to ensure this gets freed first, but I failed to find any
documentation on how this is supposed to work, so I went with a fix
that would work.

But you are obviously right, if we manually free it in the normal path
then using devm_{request,free}_irq sounds like just overhead without
benefits.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] vboxguest: add missing devm_free_irq
  2022-06-10 15:00   ` Pascal Terjan
@ 2022-06-10 16:02     ` Hans de Goede
  2022-06-12 13:37       ` [PATCH v2] vboxguest: Do not use devm for irq Pascal Terjan
  0 siblings, 1 reply; 6+ messages in thread
From: Hans de Goede @ 2022-06-10 16:02 UTC (permalink / raw)
  To: Pascal Terjan, Greg Kroah-Hartman; +Cc: Arnd Bergmann, linux-kernel

Hi,

On 6/10/22 17:00, Pascal Terjan wrote:
> On Fri, 10 Jun 2022 at 13:50, Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
>>
>> On Thu, Jun 09, 2022 at 02:40:57PM +0100, Pascal Terjan wrote:
>>> This fixes the following warning when unloading the module:
>>>
>>> [249348.837181] remove_proc_entry: removing non-empty directory 'irq/20', leaking at least 'vboxguest'
>>> [249348.837219] WARNING: CPU: 0 PID: 6708 at fs/proc/generic.c:715 remove_proc_entry+0x119/0x140
>>>
>>> [249348.837379] Call Trace:
>>> [249348.837385]  unregister_irq_proc+0xbd/0xe0
>>> [249348.837392]  free_desc+0x23/0x60
>>> [249348.837396]  irq_free_descs+0x4a/0x70
>>> [249348.837401]  irq_domain_free_irqs+0x160/0x1a0
>>> [249348.837452]  mp_unmap_irq+0x5c/0x60
>>> [249348.837458]  acpi_unregister_gsi_ioapic+0x29/0x40
>>> [249348.837463]  acpi_unregister_gsi+0x17/0x30
>>> [249348.837467]  acpi_pci_irq_disable+0xbf/0xe0
>>> [249348.837473]  pcibios_disable_device+0x20/0x30
>>> [249348.837478]  pci_disable_device+0xef/0x120
>>> [249348.837482]  vbg_pci_remove+0x6c/0x70 [vboxguest]
>>>
>>> Signed-off-by: Pascal Terjan <pterjan@google.com>
>>> ---
>>>  drivers/virt/vboxguest/vboxguest_linux.c | 1 +
>>>  1 file changed, 1 insertion(+)
>>>
>>> diff --git a/drivers/virt/vboxguest/vboxguest_linux.c b/drivers/virt/vboxguest/vboxguest_linux.c
>>> index 6e8c0f1c1056..faa4bc9f625c 100644
>>> --- a/drivers/virt/vboxguest/vboxguest_linux.c
>>> +++ b/drivers/virt/vboxguest/vboxguest_linux.c
>>> @@ -423,6 +423,7 @@ static void vbg_pci_remove(struct pci_dev *pci)
>>>       vbg_gdev = NULL;
>>>       mutex_unlock(&vbg_gdev_mutex);
>>>
>>> +     devm_free_irq(gdev->dev, pci->irq, gdev);
>>
>> The whope point of using devm_* calls is so you don't have to do stuff
>> like this.  Perhaps this should not be using devm_() for the irq at all?
> 
> My initial assumption was that some sort of dependency was missing
> somewhere to ensure this gets freed first, but I failed to find any
> documentation on how this is supposed to work, so I went with a fix
> that would work.
> 
> But you are obviously right, if we manually free it in the normal path
> then using devm_{request,free}_irq sounds like just overhead without
> benefits.

Right, please also move the irq-request over to be non devm and
also don't forgot that the error-exit path from the probe()
function also needs to free the irq before disabling the pci-dev.

Regards,

Hans


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] vboxguest: Do not use devm for irq
  2022-06-10 16:02     ` Hans de Goede
@ 2022-06-12 13:37       ` Pascal Terjan
  2022-06-12 14:13         ` Hans de Goede
  0 siblings, 1 reply; 6+ messages in thread
From: Pascal Terjan @ 2022-06-12 13:37 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Hans de Goede, Arnd Bergmann
  Cc: linux-kernel, Pascal Terjan

When relying on devm it doesn't get freed early enough which causes the
following warning when unloading the module:

[249348.837181] remove_proc_entry: removing non-empty directory 'irq/20', leaking at least 'vboxguest'
[249348.837219] WARNING: CPU: 0 PID: 6708 at fs/proc/generic.c:715 remove_proc_entry+0x119/0x140

[249348.837379] Call Trace:
[249348.837385]  unregister_irq_proc+0xbd/0xe0
[249348.837392]  free_desc+0x23/0x60
[249348.837396]  irq_free_descs+0x4a/0x70
[249348.837401]  irq_domain_free_irqs+0x160/0x1a0
[249348.837452]  mp_unmap_irq+0x5c/0x60
[249348.837458]  acpi_unregister_gsi_ioapic+0x29/0x40
[249348.837463]  acpi_unregister_gsi+0x17/0x30
[249348.837467]  acpi_pci_irq_disable+0xbf/0xe0
[249348.837473]  pcibios_disable_device+0x20/0x30
[249348.837478]  pci_disable_device+0xef/0x120
[249348.837482]  vbg_pci_remove+0x6c/0x70 [vboxguest]

Signed-off-by: Pascal Terjan <pterjan@google.com>
---
v2: stop using devm rather than adding a manual devm_free_irq

 drivers/virt/vboxguest/vboxguest_linux.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/virt/vboxguest/vboxguest_linux.c b/drivers/virt/vboxguest/vboxguest_linux.c
index 6e8c0f1c1056..dec36934d679 100644
--- a/drivers/virt/vboxguest/vboxguest_linux.c
+++ b/drivers/virt/vboxguest/vboxguest_linux.c
@@ -360,8 +360,8 @@ static int vbg_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
 		goto err_vbg_core_exit;
 	}
 
-	ret = devm_request_irq(dev, pci->irq, vbg_core_isr, IRQF_SHARED,
-			       DEVICE_NAME, gdev);
+	ret = request_irq(pci->irq, vbg_core_isr, IRQF_SHARED, DEVICE_NAME,
+			  gdev);
 	if (ret) {
 		vbg_err("vboxguest: Error requesting irq: %d\n", ret);
 		goto err_vbg_core_exit;
@@ -371,7 +371,7 @@ static int vbg_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
 	if (ret) {
 		vbg_err("vboxguest: Error misc_register %s failed: %d\n",
 			DEVICE_NAME, ret);
-		goto err_vbg_core_exit;
+		goto err_free_irq;
 	}
 
 	ret = misc_register(&gdev->misc_device_user);
@@ -407,6 +407,8 @@ static int vbg_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
 	misc_deregister(&gdev->misc_device_user);
 err_unregister_misc_device:
 	misc_deregister(&gdev->misc_device);
+err_free_irq:
+	free_irq(pci->irq, gdev);
 err_vbg_core_exit:
 	vbg_core_exit(gdev);
 err_disable_pcidev:
@@ -423,6 +425,7 @@ static void vbg_pci_remove(struct pci_dev *pci)
 	vbg_gdev = NULL;
 	mutex_unlock(&vbg_gdev_mutex);
 
+	free_irq(pci->irq, gdev);
 	device_remove_file(gdev->dev, &dev_attr_host_features);
 	device_remove_file(gdev->dev, &dev_attr_host_version);
 	misc_deregister(&gdev->misc_device_user);
-- 
2.36.1.476.g0c4daa206d-goog


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] vboxguest: Do not use devm for irq
  2022-06-12 13:37       ` [PATCH v2] vboxguest: Do not use devm for irq Pascal Terjan
@ 2022-06-12 14:13         ` Hans de Goede
  0 siblings, 0 replies; 6+ messages in thread
From: Hans de Goede @ 2022-06-12 14:13 UTC (permalink / raw)
  To: Pascal Terjan, Greg Kroah-Hartman, Arnd Bergmann; +Cc: linux-kernel

Hi,

On 6/12/22 15:37, Pascal Terjan wrote:
> When relying on devm it doesn't get freed early enough which causes the
> following warning when unloading the module:
> 
> [249348.837181] remove_proc_entry: removing non-empty directory 'irq/20', leaking at least 'vboxguest'
> [249348.837219] WARNING: CPU: 0 PID: 6708 at fs/proc/generic.c:715 remove_proc_entry+0x119/0x140
> 
> [249348.837379] Call Trace:
> [249348.837385]  unregister_irq_proc+0xbd/0xe0
> [249348.837392]  free_desc+0x23/0x60
> [249348.837396]  irq_free_descs+0x4a/0x70
> [249348.837401]  irq_domain_free_irqs+0x160/0x1a0
> [249348.837452]  mp_unmap_irq+0x5c/0x60
> [249348.837458]  acpi_unregister_gsi_ioapic+0x29/0x40
> [249348.837463]  acpi_unregister_gsi+0x17/0x30
> [249348.837467]  acpi_pci_irq_disable+0xbf/0xe0
> [249348.837473]  pcibios_disable_device+0x20/0x30
> [249348.837478]  pci_disable_device+0xef/0x120
> [249348.837482]  vbg_pci_remove+0x6c/0x70 [vboxguest]
> 
> Signed-off-by: Pascal Terjan <pterjan@google.com>
> ---
> v2: stop using devm rather than adding a manual devm_free_irq

Thanks, v2 looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans



> 
>  drivers/virt/vboxguest/vboxguest_linux.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/virt/vboxguest/vboxguest_linux.c b/drivers/virt/vboxguest/vboxguest_linux.c
> index 6e8c0f1c1056..dec36934d679 100644
> --- a/drivers/virt/vboxguest/vboxguest_linux.c
> +++ b/drivers/virt/vboxguest/vboxguest_linux.c
> @@ -360,8 +360,8 @@ static int vbg_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
>  		goto err_vbg_core_exit;
>  	}
>  
> -	ret = devm_request_irq(dev, pci->irq, vbg_core_isr, IRQF_SHARED,
> -			       DEVICE_NAME, gdev);
> +	ret = request_irq(pci->irq, vbg_core_isr, IRQF_SHARED, DEVICE_NAME,
> +			  gdev);
>  	if (ret) {
>  		vbg_err("vboxguest: Error requesting irq: %d\n", ret);
>  		goto err_vbg_core_exit;
> @@ -371,7 +371,7 @@ static int vbg_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
>  	if (ret) {
>  		vbg_err("vboxguest: Error misc_register %s failed: %d\n",
>  			DEVICE_NAME, ret);
> -		goto err_vbg_core_exit;
> +		goto err_free_irq;
>  	}
>  
>  	ret = misc_register(&gdev->misc_device_user);
> @@ -407,6 +407,8 @@ static int vbg_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
>  	misc_deregister(&gdev->misc_device_user);
>  err_unregister_misc_device:
>  	misc_deregister(&gdev->misc_device);
> +err_free_irq:
> +	free_irq(pci->irq, gdev);
>  err_vbg_core_exit:
>  	vbg_core_exit(gdev);
>  err_disable_pcidev:
> @@ -423,6 +425,7 @@ static void vbg_pci_remove(struct pci_dev *pci)
>  	vbg_gdev = NULL;
>  	mutex_unlock(&vbg_gdev_mutex);
>  
> +	free_irq(pci->irq, gdev);
>  	device_remove_file(gdev->dev, &dev_attr_host_features);
>  	device_remove_file(gdev->dev, &dev_attr_host_version);
>  	misc_deregister(&gdev->misc_device_user);


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-06-12 14:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-09 13:40 [PATCH] vboxguest: add missing devm_free_irq Pascal Terjan
2022-06-10 13:50 ` Greg Kroah-Hartman
2022-06-10 15:00   ` Pascal Terjan
2022-06-10 16:02     ` Hans de Goede
2022-06-12 13:37       ` [PATCH v2] vboxguest: Do not use devm for irq Pascal Terjan
2022-06-12 14:13         ` Hans de Goede

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).