[dpdk-dev,v2,1/4] net/dpaa: add null point check and fix mem leak
Checks
Commit Message
Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>
---
drivers/net/dpaa/dpaa_ethdev.c | 36 +++++++++++++++++++++++++-----------
1 file changed, 25 insertions(+), 11 deletions(-)
Comments
On Wednesday 20 December 2017 03:53 PM, Yong Wang wrote:
> Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>
> ---
> drivers/net/dpaa/dpaa_ethdev.c | 36 +++++++++++++++++++++++++-----------
> 1 file changed, 25 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
> index cf5a2ec..06d680c 100644
> --- a/drivers/net/dpaa/dpaa_ethdev.c
> +++ b/drivers/net/dpaa/dpaa_ethdev.c
> @@ -877,12 +877,17 @@ static int dpaa_debug_queue_init(struct qman_fq *fq, uint32_t fqid)
>
Thanks for the fix!
Reviewed-By: Shreyansh Jain <shreyansh.jain@nxp.com>
Hi,
Please could you rebase on master and keep the acked already given?
Please use --in-reply-to to keep v3 in the same thread as v2.
Titles are the same for every patches.
Are they all fixing a NULL pointer check and a mem leak?
More details in the commit message may help.
If they are fixes, a tag Fixes: may help for backports.
Thanks
SGksCkkndmUgc2VudCB0aGlzIHBhdGNoIGFnYWluIGFuZCBpdCBpcyBhY2NlcHRlZC4KVGhlIG90
aGVyIDMgcGF0aGVzIGhhdmUgbm8gY29uZmxpY3Qgd2l0aCB0aGUgbGF0ZXN0IG1hc3RlciB2ZXJz
aW9uIGFuZCB0aGUgdGl0bGVzIGhhdmUgZGVzY3JpYmVkIHRoZSBtb2RpZmljYXRpb24gb2YgdGhl
IHBhdGNoZXMuClNvIEkgbmVlZCBub3Qgc2VuZCB0aGUgcGF0Y2hlcyBmb3IgdjMsIHJpZ2h0PwoK
CgoKLS0tLS0tLS0tLS0tLS0tLS0tb3JpZ2luLS0tLS0tLS0tLS0tLS0tLS0tCkZyb20g77yaIDx0
aG9tYXNAbW9uamFsb24ubmV0PjsKdG8g77yad2FuZy55b25nMTlAenRlLmNvbS5jbjsKY2PvvJog
PGRldkBkcGRrLm9yZz47IDxoZW1hbnQuYWdyYXdhbEBueHAuY29tPjsgPGJlaWxlaS54aW5nQGlu
dGVsLmNvbT47IDx3ZW56aHVvLmx1QGludGVsLmNvbT47IDxqb2huLmdyaWZmaW5AaW50ZWwuY29t
PjsKZGF0ZSDvvJoyMDE4LTAxLTE4IDA3OjAwCnN1YmplY3Qg77yaUmU6IFtkcGRrLWRldl0gW1BB
VENIIHYyIDEvNF0gbmV0L2RwYWE6IGFkZCBudWxsIHBvaW50IGNoZWNrIGFuZCBmaXggbWVtIGxl
YWsKSGksCgpQbGVhc2UgY291bGQgeW91IHJlYmFzZSBvbiBtYXN0ZXIgYW5kIGtlZXAgdGhlIGFj
a2VkIGFscmVhZHkgZ2l2ZW4/ClBsZWFzZSB1c2UgLS1pbi1yZXBseS10byB0byBrZWVwIHYzIGlu
IHRoZSBzYW1lIHRocmVhZCBhcyB2Mi4KClRpdGxlcyBhcmUgdGhlIHNhbWUgZm9yIGV2ZXJ5IHBh
dGNoZXMuCkFyZSB0aGV5IGFsbCBmaXhpbmcgYSBOVUxMIHBvaW50ZXIgY2hlY2sgYW5kIGEgbWVt
IGxlYWs/Ck1vcmUgZGV0YWlscyBpbiB0aGUgY29tbWl0IG1lc3NhZ2UgbWF5IGhlbHAuCgpJZiB0
aGV5IGFyZSBmaXhlcywgYSB0YWcgRml4ZXM6IG1heSBoZWxwIGZvciBiYWNrcG9ydHMuCgpUaGFu
a3M=
Hi,
22/01/2018 03:53, wang.yong19@zte.com.cn:
> Hi,
> I've sent this patch again and it is accepted.
> The other 3 pathes have no conflict with the latest master version and the titles have described the modification of the patches.
> So I need not send the patches for v3, right?
Please re-send those which are not integrated yet,
with more details, and appropriate title.
Thanks
> ------------------origin------------------
> From : <thomas@monjalon.net>;
> to :wang.yong19@zte.com.cn;
> cc: <dev@dpdk.org>; <hemant.agrawal@nxp.com>; <beilei.xing@intel.com>; <wenzhuo.lu@intel.com>; <john.griffin@intel.com>;
> date :2018-01-18 07:00
> subject :Re: [dpdk-dev] [PATCH v2 1/4] net/dpaa: add null point check and fix mem leak
> Hi,
>
> Please could you rebase on master and keep the acked already given?
> Please use --in-reply-to to keep v3 in the same thread as v2.
>
> Titles are the same for every patches.
> Are they all fixing a NULL pointer check and a mem leak?
> More details in the commit message may help.
>
> If they are fixes, a tag Fixes: may help for backports.
>
> Thanks
@@ -877,12 +877,17 @@ static int dpaa_debug_queue_init(struct qman_fq *fq, uint32_t fqid)
dpaa_intf->rx_queues = rte_zmalloc(NULL,
sizeof(struct qman_fq) * num_rx_fqs, MAX_CACHELINE);
+ if (!dpaa_intf->rx_queues) {
+ DPAA_PMD_ERR("Failed to alloc mem for RX queues\n");
+ return -ENOMEM;
+ }
+
for (loop = 0; loop < num_rx_fqs; loop++) {
fqid = DPAA_PCD_FQID_START + dpaa_intf->ifid *
DPAA_PCD_FQID_MULTIPLIER + loop;
ret = dpaa_rx_queue_init(&dpaa_intf->rx_queues[loop], fqid);
if (ret)
- return ret;
+ goto free_rx;
dpaa_intf->rx_queues[loop].dpaa_intf = dpaa_intf;
}
dpaa_intf->nb_rx_queues = num_rx_fqs;
@@ -891,14 +896,17 @@ static int dpaa_debug_queue_init(struct qman_fq *fq, uint32_t fqid)
num_cores = rte_lcore_count();
dpaa_intf->tx_queues = rte_zmalloc(NULL, sizeof(struct qman_fq) *
num_cores, MAX_CACHELINE);
- if (!dpaa_intf->tx_queues)
- return -ENOMEM;
+ if (!dpaa_intf->tx_queues) {
+ DPAA_PMD_ERR("Failed to alloc mem for TX queues\n");
+ ret = -ENOMEM;
+ goto free_rx;
+ }
for (loop = 0; loop < num_cores; loop++) {
ret = dpaa_tx_queue_init(&dpaa_intf->tx_queues[loop],
fman_intf);
if (ret)
- return ret;
+ goto free_tx;
dpaa_intf->tx_queues[loop].dpaa_intf = dpaa_intf;
}
dpaa_intf->nb_tx_queues = num_cores;
@@ -935,13 +943,8 @@ static int dpaa_debug_queue_init(struct qman_fq *fq, uint32_t fqid)
DPAA_PMD_ERR("Failed to allocate %d bytes needed to "
"store MAC addresses",
ETHER_ADDR_LEN * DPAA_MAX_MAC_FILTER);
- rte_free(dpaa_intf->rx_queues);
- rte_free(dpaa_intf->tx_queues);
- dpaa_intf->rx_queues = NULL;
- dpaa_intf->tx_queues = NULL;
- dpaa_intf->nb_rx_queues = 0;
- dpaa_intf->nb_tx_queues = 0;
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto free_tx;
}
/* copy the primary mac address */
@@ -967,6 +970,17 @@ static int dpaa_debug_queue_init(struct qman_fq *fq, uint32_t fqid)
fman_if_stats_reset(fman_intf);
return 0;
+
+free_tx:
+ rte_free(dpaa_intf->tx_queues);
+ dpaa_intf->tx_queues = NULL;
+ dpaa_intf->nb_tx_queues = 0;
+
+free_rx:
+ rte_free(dpaa_intf->rx_queues);
+ dpaa_intf->rx_queues = NULL;
+ dpaa_intf->nb_rx_queues = 0;
+ return ret;
}
static int