Code Review
/
deb_dpdk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
New upstream version 17.11.5
[deb_dpdk.git]
/
drivers
/
net
/
nfp
/
nfp_nspu.c
diff --git
a/drivers/net/nfp/nfp_nspu.c
b/drivers/net/nfp/nfp_nspu.c
index
6ba940c
..
d4abb6c
100644
(file)
--- a/
drivers/net/nfp/nfp_nspu.c
+++ b/
drivers/net/nfp/nfp_nspu.c
@@
-9,6
+9,7
@@
#include <rte_log.h>
#include <rte_byteorder.h>
#include <rte_log.h>
#include <rte_byteorder.h>
+#include <rte_string_fns.h>
#include "nfp_nfpu.h"
#include "nfp_nfpu.h"
@@
-341,7
+342,12
@@
nfp_fw_upload(nspu_desc_t *nspu_desc)
return -ENOENT;
}
return -ENOENT;
}
- fstat(fw_f, &file_stat);
+ if (fstat(fw_f, &file_stat) < 0) {
+ RTE_LOG(INFO, PMD, "Firmware file %s/%s size is unknown",
+ DEFAULT_FW_PATH, DEFAULT_FW_FILENAME);
+ close(fw_f);
+ return -ENOENT;
+ }
fsize = file_stat.st_size;
RTE_LOG(DEBUG, PMD, "Firmware file with size: %" PRIu64 "\n",
fsize = file_stat.st_size;
RTE_LOG(DEBUG, PMD, "Firmware file with size: %" PRIu64 "\n",
@@
-351,12
+357,14
@@
nfp_fw_upload(nspu_desc_t *nspu_desc)
RTE_LOG(INFO, PMD, "fw file too big: %" PRIu64
" bytes (%" PRIu64 " max)",
(uint64_t)fsize, (uint64_t)size);
RTE_LOG(INFO, PMD, "fw file too big: %" PRIu64
" bytes (%" PRIu64 " max)",
(uint64_t)fsize, (uint64_t)size);
+ close(fw_f);
return -EINVAL;
}
fw_buf = malloc((size_t)size);
if (!fw_buf) {
RTE_LOG(INFO, PMD, "malloc failed for fw buffer");
return -EINVAL;
}
fw_buf = malloc((size_t)size);
if (!fw_buf) {
RTE_LOG(INFO, PMD, "malloc failed for fw buffer");
+ close(fw_f);
return -ENOMEM;
}
memset(fw_buf, 0, size);
return -ENOMEM;
}
memset(fw_buf, 0, size);
@@
-367,12
+375,14
@@
nfp_fw_upload(nspu_desc_t *nspu_desc)
"Just %" PRIu64 " of %" PRIu64 " bytes read.",
(uint64_t)bytes, (uint64_t)fsize);
free(fw_buf);
"Just %" PRIu64 " of %" PRIu64 " bytes read.",
(uint64_t)bytes, (uint64_t)fsize);
free(fw_buf);
+ close(fw_f);
return -EIO;
}
ret = nspu_command(nspu_desc, NSP_CMD_FW_LOAD, 0, 1, fw_buf, 0, bytes);
free(fw_buf);
return -EIO;
}
ret = nspu_command(nspu_desc, NSP_CMD_FW_LOAD, 0, 1, fw_buf, 0, bytes);
free(fw_buf);
+ close(fw_f);
return ret;
}
return ret;
}
@@
-411,7
+421,12
@@
nfp_nspu_set_bar_from_symbl(nspu_desc_t *desc, const char *symbl,
int ret = 0;
sym_buf = malloc(desc->buf_size);
int ret = 0;
sym_buf = malloc(desc->buf_size);
- strncpy(sym_buf, symbl, strlen(symbl));
+ if (!sym_buf)
+ return -ENOMEM;
+
+ memset(sym_buf, 0, desc->buf_size);
+ memcpy(sym_buf, symbl, strlen(symbl));
+
ret = nspu_command(desc, NSP_CMD_GET_SYMBOL, 1, 1, sym_buf,
NFP_SYM_DESC_LEN, strlen(symbl));
if (ret) {
ret = nspu_command(desc, NSP_CMD_GET_SYMBOL, 1, 1, sym_buf,
NFP_SYM_DESC_LEN, strlen(symbl));
if (ret) {
@@
-554,6
+569,7
@@
nfp_nsp_eth_config(nspu_desc_t *desc, int port, int up)
NSP_ETH_TABLE_SIZE, 0);
if (ret) {
rte_spinlock_unlock(&desc->nsp_lock);
NSP_ETH_TABLE_SIZE, 0);
if (ret) {
rte_spinlock_unlock(&desc->nsp_lock);
+ free(entries);
return ret;
}
return ret;
}
@@
-574,6
+590,7
@@
nfp_nsp_eth_config(nspu_desc_t *desc, int port, int up)
if (i == NSP_ETH_MAX_COUNT) {
rte_spinlock_unlock(&desc->nsp_lock);
if (i == NSP_ETH_MAX_COUNT) {
rte_spinlock_unlock(&desc->nsp_lock);
+ free(entries);
return -EINVAL;
}
return -EINVAL;
}
@@
-598,6
+615,7
@@
nfp_nsp_eth_config(nspu_desc_t *desc, int port, int up)
"Hw ethernet port %d configure failed\n", port);
}
rte_spinlock_unlock(&desc->nsp_lock);
"Hw ethernet port %d configure failed\n", port);
}
rte_spinlock_unlock(&desc->nsp_lock);
+ free(entries);
return ret;
}
return ret;
}
@@
-606,10
+624,14
@@
nfp_nsp_eth_read_table(nspu_desc_t *desc, union eth_table_entry **table)
{
int ret;
{
int ret;
+ if (!table)
+ return -EINVAL;
+
RTE_LOG(INFO, PMD, "Reading hw ethernet table...\n");
RTE_LOG(INFO, PMD, "Reading hw ethernet table...\n");
+
/* port 0 allocates the eth table and read it using NSPU */
*table = malloc(NSP_ETH_TABLE_SIZE);
/* port 0 allocates the eth table and read it using NSPU */
*table = malloc(NSP_ETH_TABLE_SIZE);
- if (!table)
+ if (!
*
table)
return -ENOMEM;
ret = nspu_command(desc, NSP_CMD_READ_ETH_TABLE, 1, 0, *table,
return -ENOMEM;
ret = nspu_command(desc, NSP_CMD_READ_ETH_TABLE, 1, 0, *table,