qed: Add cleanup in qed_slowpath_start()
diff mbox series

Message ID 1565690709-3186-1-git-send-email-wenwen@cs.uga.edu
State Changes Requested
Delegated to: David Miller
Headers show
Series
  • qed: Add cleanup in qed_slowpath_start()
Related show

Commit Message

Wenwen Wang Aug. 13, 2019, 10:05 a.m. UTC
If qed_mcp_send_drv_version() fails, no cleanup is executed, leading to
memory leaks. To fix this issue, redirect the execution to the label 'err3'
before returning the error.

Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
---
 drivers/net/ethernet/qlogic/qed/qed_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Sudarsana Reddy Kalluru Aug. 13, 2019, 10:46 a.m. UTC | #1
> -----Original Message-----
> From: Wenwen Wang <wenwen@cs.uga.edu>
> Sent: Tuesday, August 13, 2019 3:35 PM
> To: Wenwen Wang <wenwen@cs.uga.edu>
> Cc: Ariel Elior <aelior@marvell.com>; GR-everest-linux-l2 <GR-everest-linux-
> l2@marvell.com>; David S. Miller <davem@davemloft.net>; open
> list:QLOGIC QL4xxx ETHERNET DRIVER <netdev@vger.kernel.org>; open list
> <linux-kernel@vger.kernel.org>
> Subject: [EXT] [PATCH] qed: Add cleanup in qed_slowpath_start()
> 
> External Email
> 
> ----------------------------------------------------------------------
> If qed_mcp_send_drv_version() fails, no cleanup is executed, leading to
> memory leaks. To fix this issue, redirect the execution to the label 'err3'
> before returning the error.
> 
> Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
> ---
>  drivers/net/ethernet/qlogic/qed/qed_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c
> b/drivers/net/ethernet/qlogic/qed/qed_main.c
> index 829dd60..d16a251 100644
> --- a/drivers/net/ethernet/qlogic/qed/qed_main.c
> +++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
> @@ -1325,7 +1325,7 @@ static int qed_slowpath_start(struct qed_dev
> *cdev,
>  					      &drv_version);
>  		if (rc) {
>  			DP_NOTICE(cdev, "Failed sending drv version
> command\n");
> -			return rc;
> +			goto err3;

In this case, we might need to free the ll2-buf allocated at the below path (?),
1312         /* Allocate LL2 interface if needed */
1313         if (QED_LEADING_HWFN(cdev)->using_ll2) {
1314                 rc = qed_ll2_alloc_if(cdev);
May be by adding a new goto label 'err4'.

>  		}
>  	}
> 
> --
> 2.7.4
Wenwen Wang Aug. 21, 2019, 4:31 a.m. UTC | #2
On Tue, Aug 13, 2019 at 6:46 AM Sudarsana Reddy Kalluru
<skalluru@marvell.com> wrote:
>
> > -----Original Message-----
> > From: Wenwen Wang <wenwen@cs.uga.edu>
> > Sent: Tuesday, August 13, 2019 3:35 PM
> > To: Wenwen Wang <wenwen@cs.uga.edu>
> > Cc: Ariel Elior <aelior@marvell.com>; GR-everest-linux-l2 <GR-everest-linux-
> > l2@marvell.com>; David S. Miller <davem@davemloft.net>; open
> > list:QLOGIC QL4xxx ETHERNET DRIVER <netdev@vger.kernel.org>; open list
> > <linux-kernel@vger.kernel.org>
> > Subject: [EXT] [PATCH] qed: Add cleanup in qed_slowpath_start()
> >
> > External Email
> >
> > ----------------------------------------------------------------------
> > If qed_mcp_send_drv_version() fails, no cleanup is executed, leading to
> > memory leaks. To fix this issue, redirect the execution to the label 'err3'
> > before returning the error.
> >
> > Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
> > ---
> >  drivers/net/ethernet/qlogic/qed/qed_main.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c
> > b/drivers/net/ethernet/qlogic/qed/qed_main.c
> > index 829dd60..d16a251 100644
> > --- a/drivers/net/ethernet/qlogic/qed/qed_main.c
> > +++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
> > @@ -1325,7 +1325,7 @@ static int qed_slowpath_start(struct qed_dev
> > *cdev,
> >                                             &drv_version);
> >               if (rc) {
> >                       DP_NOTICE(cdev, "Failed sending drv version
> > command\n");
> > -                     return rc;
> > +                     goto err3;
>
> In this case, we might need to free the ll2-buf allocated at the below path (?),
> 1312         /* Allocate LL2 interface if needed */
> 1313         if (QED_LEADING_HWFN(cdev)->using_ll2) {
> 1314                 rc = qed_ll2_alloc_if(cdev);
> May be by adding a new goto label 'err4'.

Thanks for your suggestion! I will rework the patch.

Wenwen

>
> >               }
> >       }
> >
> > --
> > 2.7.4
>

Patch
diff mbox series

diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c b/drivers/net/ethernet/qlogic/qed/qed_main.c
index 829dd60..d16a251 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_main.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
@@ -1325,7 +1325,7 @@  static int qed_slowpath_start(struct qed_dev *cdev,
 					      &drv_version);
 		if (rc) {
 			DP_NOTICE(cdev, "Failed sending drv version command\n");
-			return rc;
+			goto err3;
 		}
 	}