[dpdk-dev,02/21] net/qede/base: fix to set pointers to NULL after freeing
Checks
Commit Message
Set pointers to NULL after freeing the allocations on ecore_resc_free().
Fixes: 26ae839d06e9 ("qede: add DCBX support")
Fixes: ec94dbc57362 ("qede: add base driver")
Signed-off-by: Rasesh Mody <rasesh.mody@cavium.com>
---
drivers/net/qede/base/ecore_dcbx.c | 2 +-
drivers/net/qede/base/ecore_dev.c | 4 ++--
drivers/net/qede/base/ecore_spq.c | 2 ++
3 files changed, 5 insertions(+), 3 deletions(-)
Comments
On 2/27/2017 7:51 AM, Rasesh Mody wrote:
> Set pointers to NULL after freeing the allocations on ecore_resc_free().
>
> Fixes: 26ae839d06e9 ("qede: add DCBX support")
> Fixes: ec94dbc57362 ("qede: add base driver")
>
> Signed-off-by: Rasesh Mody <rasesh.mody@cavium.com>
> ---
> drivers/net/qede/base/ecore_dcbx.c | 2 +-
> drivers/net/qede/base/ecore_dev.c | 4 ++--
> drivers/net/qede/base/ecore_spq.c | 2 ++
> 3 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/qede/base/ecore_dcbx.c b/drivers/net/qede/base/ecore_dcbx.c
> index 7380fd8..9ce6dc4 100644
> --- a/drivers/net/qede/base/ecore_dcbx.c
> +++ b/drivers/net/qede/base/ecore_dcbx.c
> @@ -914,7 +914,7 @@ enum _ecore_status_t ecore_dcbx_info_alloc(struct ecore_hwfn *p_hwfn)
> void ecore_dcbx_info_free(struct ecore_hwfn *p_hwfn,
> struct ecore_dcbx_info *p_dcbx_info)
> {
> - OSAL_FREE(p_hwfn->p_dev, p_hwfn->p_dcbx_info);
> + p_hwfn->p_dcbx_info = OSAL_NULL;
Is replacing free with "NULL assignment" intentional?
From commit log and other updates in this patch, intention looks like
setting pointers to NULL after freeing them.
> }
>
> static void ecore_dcbx_update_protocol_data(struct protocol_dcb_data *p_data,
> diff --git a/drivers/net/qede/base/ecore_dev.c b/drivers/net/qede/base/ecore_dev.c
> index 0518fc7..15051b6 100644
> --- a/drivers/net/qede/base/ecore_dev.c
> +++ b/drivers/net/qede/base/ecore_dev.c
> @@ -156,6 +156,7 @@ void ecore_resc_free(struct ecore_dev *p_dev)
> p_dev->fw_data = OSAL_NULL;
>
> OSAL_FREE(p_dev, p_dev->reset_stats);
> + p_dev->reset_stats = OSAL_NULL;
Since already a macro used for free, does it make sense to make NULL
assignment part of macro?
> From: Ferruh Yigit [mailto:ferruh.yigit@intel.com]
> Sent: Thursday, March 02, 2017 5:05 AM
>
> On 2/27/2017 7:51 AM, Rasesh Mody wrote:
> > Set pointers to NULL after freeing the allocations on ecore_resc_free().
> >
> > Fixes: 26ae839d06e9 ("qede: add DCBX support")
> > Fixes: ec94dbc57362 ("qede: add base driver")
> >
> > Signed-off-by: Rasesh Mody <rasesh.mody@cavium.com>
> > ---
> > drivers/net/qede/base/ecore_dcbx.c | 2 +-
> > drivers/net/qede/base/ecore_dev.c | 4 ++--
> > drivers/net/qede/base/ecore_spq.c | 2 ++
> > 3 files changed, 5 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/net/qede/base/ecore_dcbx.c
> > b/drivers/net/qede/base/ecore_dcbx.c
> > index 7380fd8..9ce6dc4 100644
> > --- a/drivers/net/qede/base/ecore_dcbx.c
> > +++ b/drivers/net/qede/base/ecore_dcbx.c
> > @@ -914,7 +914,7 @@ enum _ecore_status_t
> ecore_dcbx_info_alloc(struct
> > ecore_hwfn *p_hwfn) void ecore_dcbx_info_free(struct ecore_hwfn
> *p_hwfn,
> > struct ecore_dcbx_info *p_dcbx_info) {
> > - OSAL_FREE(p_hwfn->p_dev, p_hwfn->p_dcbx_info);
> > + p_hwfn->p_dcbx_info = OSAL_NULL;
>
>
> Is replacing free with "NULL assignment" intentional?
It was an oversight, good catch, incorporated in v2 series, thanks.
>
> From commit log and other updates in this patch, intention looks like
> setting pointers to NULL after freeing them.
>
> > }
> >
> > static void ecore_dcbx_update_protocol_data(struct protocol_dcb_data
> *p_data,
> > diff --git a/drivers/net/qede/base/ecore_dev.c
> b/drivers/net/qede/base/ecore_dev.c
> > index 0518fc7..15051b6 100644
> > --- a/drivers/net/qede/base/ecore_dev.c
> > +++ b/drivers/net/qede/base/ecore_dev.c
> > @@ -156,6 +156,7 @@ void ecore_resc_free(struct ecore_dev *p_dev)
> > p_dev->fw_data = OSAL_NULL;
> >
> > OSAL_FREE(p_dev, p_dev->reset_stats);
> > + p_dev->reset_stats = OSAL_NULL;
>
> Since already a macro used for free, does it make sense to make NULL
> assignment part of macro?
Incorporated in v2 series.
@@ -914,7 +914,7 @@ enum _ecore_status_t ecore_dcbx_info_alloc(struct ecore_hwfn *p_hwfn)
void ecore_dcbx_info_free(struct ecore_hwfn *p_hwfn,
struct ecore_dcbx_info *p_dcbx_info)
{
- OSAL_FREE(p_hwfn->p_dev, p_hwfn->p_dcbx_info);
+ p_hwfn->p_dcbx_info = OSAL_NULL;
}
static void ecore_dcbx_update_protocol_data(struct protocol_dcb_data *p_data,
@@ -156,6 +156,7 @@ void ecore_resc_free(struct ecore_dev *p_dev)
p_dev->fw_data = OSAL_NULL;
OSAL_FREE(p_dev, p_dev->reset_stats);
+ p_dev->reset_stats = OSAL_NULL;
for_each_hwfn(p_dev, i) {
struct ecore_hwfn *p_hwfn = &p_dev->hwfns[i];
@@ -668,8 +669,7 @@ enum _ecore_status_t ecore_resc_alloc(struct ecore_dev *p_dev)
DP_ERR(p_hwfn, "Cannot allocate 0x%x EQ elements."
"The maximum of a u16 chain is 0x%x\n",
n_eqes, 0xFFFF);
- rc = ECORE_INVAL;
- goto alloc_err;
+ goto alloc_no_mem;
}
p_eq = ecore_eq_alloc(p_hwfn, (u16)n_eqes);
@@ -402,6 +402,7 @@ void ecore_eq_free(struct ecore_hwfn *p_hwfn, struct ecore_eq *p_eq)
return;
ecore_chain_free(p_hwfn->p_dev, &p_eq->chain);
OSAL_FREE(p_hwfn->p_dev, p_eq);
+ p_eq = OSAL_NULL;
}
/***************************************************************************
@@ -987,4 +988,5 @@ void ecore_consq_free(struct ecore_hwfn *p_hwfn, struct ecore_consq *p_consq)
return;
ecore_chain_free(p_hwfn->p_dev, &p_consq->chain);
OSAL_FREE(p_hwfn->p_dev, p_consq);
+ p_consq = OSAL_NULL;
}