From: Serhii Iliushyk <sil-plv@napatech.com>
To: dev@dpdk.org
Cc: mko-plv@napatech.com, sil-plv@napatech.com, ckm@napatech.com,
stephen@networkplumber.org, thomas@monjalon.net
Subject: [PATCH v1 4/5] net/ntnic: check result of malloc
Date: Fri, 7 Mar 2025 22:51:34 +0100 [thread overview]
Message-ID: <20250307215136.3110019-5-sil-plv@napatech.com> (raw)
In-Reply-To: <20250307215136.3110019-1-sil-plv@napatech.com>
Check return value from the malloc code
Signed-off-by: Serhii Iliushyk <sil-plv@napatech.com>
---
drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c | 10 ++++++----
drivers/net/ntnic/nthw/nthw_rac.c | 5 ++++-
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c b/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c
index 222a553684..6ee3beb7bd 100644
--- a/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c
+++ b/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c
@@ -822,8 +822,9 @@ nthw_setup_mngd_rx_virt_queue_split(nthw_dbs_t *p_nthw_dbs,
if (p_packet_buffers) {
rxvq[index].p_virtual_addr = malloc(queue_size * sizeof(*p_packet_buffers));
- memcpy(rxvq[index].p_virtual_addr, p_packet_buffers,
- queue_size * sizeof(*p_packet_buffers));
+ if (rxvq[index].p_virtual_addr)
+ memcpy(rxvq[index].p_virtual_addr, p_packet_buffers,
+ queue_size * sizeof(*p_packet_buffers));
}
nthw_setup_rx_virt_queue(p_nthw_dbs, index, 0, 0, (void *)p_virt_struct_area->phys_addr,
@@ -878,8 +879,9 @@ nthw_setup_mngd_tx_virt_queue_split(nthw_dbs_t *p_nthw_dbs,
if (p_packet_buffers) {
txvq[index].p_virtual_addr = malloc(queue_size * sizeof(*p_packet_buffers));
- memcpy(txvq[index].p_virtual_addr, p_packet_buffers,
- queue_size * sizeof(*p_packet_buffers));
+ if (txvq[index].p_virtual_addr)
+ memcpy(txvq[index].p_virtual_addr, p_packet_buffers,
+ queue_size * sizeof(*p_packet_buffers));
}
nthw_setup_tx_virt_queue(p_nthw_dbs, index, 0, 0, (void *)p_virt_struct_area->phys_addr,
diff --git a/drivers/net/ntnic/nthw/nthw_rac.c b/drivers/net/ntnic/nthw/nthw_rac.c
index c22123d936..2257dfb7dc 100644
--- a/drivers/net/ntnic/nthw/nthw_rac.c
+++ b/drivers/net/ntnic/nthw/nthw_rac.c
@@ -31,7 +31,10 @@
nthw_rac_t *nthw_rac_new(void)
{
nthw_rac_t *p = malloc(sizeof(nthw_rac_t));
- memset(p, 0, sizeof(nthw_rac_t));
+
+ if (p)
+ memset(p, 0, sizeof(nthw_rac_t));
+
return p;
}
--
2.45.0
next prev parent reply other threads:[~2025-03-07 21:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-07 21:51 [PATCH v1 0/5] bugfixes and cleanup Serhii Iliushyk
2025-03-07 21:51 ` [PATCH v1 1/5] net/ntnic: add SPDX tag Serhii Iliushyk
2025-03-07 21:51 ` [PATCH v1 2/5] net/ntnic: rename clock registers file Serhii Iliushyk
2025-03-07 21:51 ` [PATCH v1 3/5] net/ntnic: replace assert with RTE assert Serhii Iliushyk
2025-03-07 21:51 ` Serhii Iliushyk [this message]
2025-03-07 21:51 ` [PATCH v1 5/5] net/ntnic: add nthw prefix function names Serhii Iliushyk
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=20250307215136.3110019-5-sil-plv@napatech.com \
--to=sil-plv@napatech.com \
--cc=ckm@napatech.com \
--cc=dev@dpdk.org \
--cc=mko-plv@napatech.com \
--cc=stephen@networkplumber.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).