linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: rtl8192e: set priv->irq as 0 after the irq is freed
@ 2017-10-28  6:33 Arvind Yadav
  2017-10-31 10:59 ` Dan Carpenter
  0 siblings, 1 reply; 2+ messages in thread
From: Arvind Yadav @ 2017-10-28  6:33 UTC (permalink / raw)
  To: gregkh, robsonde, tvboxspy, mayhs11saini; +Cc: linux-kernel, devel

_rtl92e_init can fail here, we must set priv->irq as 0 after free_irq.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
index aca5265..1ea1142 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
@@ -1095,6 +1095,7 @@ static short _rtl92e_init(struct net_device *dev)
 	if (_rtl92e_pci_initdescring(dev) != 0) {
 		netdev_err(dev, "Endopoints initialization failed");
 		free_irq(dev->irq, dev);
+		priv->irq = 0;
 		return -1;
 	}
 
-- 
2.7.4

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

* Re: [PATCH] staging: rtl8192e: set priv->irq as 0 after the irq is freed
  2017-10-28  6:33 [PATCH] staging: rtl8192e: set priv->irq as 0 after the irq is freed Arvind Yadav
@ 2017-10-31 10:59 ` Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2017-10-31 10:59 UTC (permalink / raw)
  To: Arvind Yadav
  Cc: gregkh, robsonde, tvboxspy, mayhs11saini, devel, linux-kernel

On Sat, Oct 28, 2017 at 12:03:46PM +0530, Arvind Yadav wrote:
> _rtl92e_init can fail here, we must set priv->irq as 0 after free_irq.
> 

The changelog isn't useful.  It should say that we are doing this
because we call free_irq() again in _rtl92e_pci_probe() so it's a double
free.

This fix won't work.  _rtl92e_pci_probe() doesn't check if priv->irq is
zero, and also it frees dev->irq which is different from priv->irq.  We
should really just get rid of priv->irq.

Really each allocation function should have a corresponding free
function so there should be a _rtl92e_undo_init() which frees the memory
and the IRQ.  Currently we just free the IRQ and leak the memory.

Anyway, the right fix is to just do this:

--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
@@ -2524,7 +2524,7 @@ static int _rtl92e_pci_probe(struct pci_dev *pdev,
        RT_TRACE(COMP_INIT, "Driver probe completed1\n");
        if (_rtl92e_init(dev) != 0) {
                netdev_warn(dev, "Initialization failed");
-               goto err_free_irq;
+               goto err_unmap;
        }
 
        netif_carrier_off(dev);

_rtl92e_init() is a useless name as well...  :/  It would be nice to
preserve the error codes, except they are all -1 which is lazy and
wrong.

regards,
dan carpenter

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

end of thread, other threads:[~2017-10-31 11:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-28  6:33 [PATCH] staging: rtl8192e: set priv->irq as 0 after the irq is freed Arvind Yadav
2017-10-31 10:59 ` Dan Carpenter

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).