DPDK patches and discussions
 help / color / mirror / Atom feed
From: Yongseok Koh <yskoh@mellanox.com>
To: Raslan Darawsheh <rasland@mellanox.com>
Cc: Shahaf Shuler <shahafs@mellanox.com>,
	"dev@dpdk.org" <dev@dpdk.org>,
	Thomas Monjalon <thomas@monjalon.net>,
	Ophir Munk <ophirmu@mellanox.com>,
	"stable@dpdk.org" <stable@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH 1/2] net/mlx5: fix multiple free issue when attr	ctx is NULL
Date: Mon, 7 May 2018 17:14:22 +0000	[thread overview]
Message-ID: <2027735E-4EF9-4ED1-AC07-7E2AF59263FC@mellanox.com> (raw)
In-Reply-To: <1525695534-15072-1-git-send-email-rasland@mellanox.com>


> On May 7, 2018, at 5:18 AM, Raslan Darawsheh <rasland@mellanox.com> wrote:

Please don't use PMD/code specific words in the title. I suggest:
	net/mlx5: fix double free on error handling

> When attr_ctx is NULL it will attempt to free the list of devices twice.
> So, changing it to be freed in error handling only.
> 
> Fixes: 771fa900 ("mlx5: introduce new driver for Mellanox ConnectX-4 adapters")

Prefer to put 12 figures?

> Cc: stable@dpdk.org

New line here.

> Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
> ---
> drivers/net/mlx5/mlx5.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
> index 5190b9f..d34076b 100644
> --- a/drivers/net/mlx5/mlx5.c
> +++ b/drivers/net/mlx5/mlx5.c
> @@ -690,7 +690,6 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
> 		break;
> 	}
> 	if (attr_ctx == NULL) {
> -		mlx5_glue->free_device_list(list);
> 		switch (err) {
> 		case 0:
> 			DRV_LOG(ERR,
> @@ -701,6 +700,8 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
> 			DRV_LOG(ERR,
> 				"cannot use device, are drivers up to date?");
> 			goto error;
> +		default:
> +			goto error;
> 		}
> 	}
> 	ibv_dev = list[i];
> -- 

Nice catch!
Looks the goto lines are redundant. How about this instead?

diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 5190b9fcd..270f59b27 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -690,18 +690,16 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
                break;
        }
        if (attr_ctx == NULL) {
-               mlx5_glue->free_device_list(list);
                switch (err) {
                case 0:
                        DRV_LOG(ERR,
                                "cannot access device, is mlx5_ib loaded?");
                        err = ENODEV;
-                       goto error;
                case EINVAL:
                        DRV_LOG(ERR,
                                "cannot use device, are drivers up to date?");
-                       goto error;
                }
+               goto error;
        }
        ibv_dev = list[i];
        DRV_LOG(DEBUG, "device opened");


Thanks,
Yongseok

  parent reply	other threads:[~2018-05-07 17:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-07 12:18 Raslan Darawsheh
2018-05-07 12:18 ` [dpdk-dev] [PATCH 2/2] net/mlx5: add free for eth dev port in case of error Raslan Darawsheh
2018-05-07 17:14 ` Yongseok Koh [this message]
2018-05-07 17:22   ` [dpdk-dev] [PATCH 1/2] net/mlx5: fix multiple free issue when attr ctx is NULL Raslan Darawsheh

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=2027735E-4EF9-4ED1-AC07-7E2AF59263FC@mellanox.com \
    --to=yskoh@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=ophirmu@mellanox.com \
    --cc=rasland@mellanox.com \
    --cc=shahafs@mellanox.com \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net \
    /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 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).