Skip to content

Commit 336893b

Browse files
sil-plvshemminger
authored andcommitted
net/ntnic: check result of malloc
Check return value from the malloc code Signed-off-by: Serhii Iliushyk <[email protected]>
1 parent 78c2c96 commit 336893b

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -822,8 +822,9 @@ nthw_setup_mngd_rx_virt_queue_split(nthw_dbs_t *p_nthw_dbs,
822822

823823
if (p_packet_buffers) {
824824
rxvq[index].p_virtual_addr = malloc(queue_size * sizeof(*p_packet_buffers));
825-
memcpy(rxvq[index].p_virtual_addr, p_packet_buffers,
826-
queue_size * sizeof(*p_packet_buffers));
825+
if (rxvq[index].p_virtual_addr)
826+
memcpy(rxvq[index].p_virtual_addr, p_packet_buffers,
827+
queue_size * sizeof(*p_packet_buffers));
827828
}
828829

829830
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,
878879

879880
if (p_packet_buffers) {
880881
txvq[index].p_virtual_addr = malloc(queue_size * sizeof(*p_packet_buffers));
881-
memcpy(txvq[index].p_virtual_addr, p_packet_buffers,
882-
queue_size * sizeof(*p_packet_buffers));
882+
if (txvq[index].p_virtual_addr)
883+
memcpy(txvq[index].p_virtual_addr, p_packet_buffers,
884+
queue_size * sizeof(*p_packet_buffers));
883885
}
884886

885887
nthw_setup_tx_virt_queue(p_nthw_dbs, index, 0, 0, (void *)p_virt_struct_area->phys_addr,

drivers/net/ntnic/nthw/nthw_rac.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@
3131
nthw_rac_t *nthw_rac_new(void)
3232
{
3333
nthw_rac_t *p = malloc(sizeof(nthw_rac_t));
34-
memset(p, 0, sizeof(nthw_rac_t));
34+
35+
if (p)
36+
memset(p, 0, sizeof(nthw_rac_t));
37+
3538
return p;
3639
}
3740

0 commit comments

Comments
 (0)