This patch fixes null pointer dereference issues found by coverity scan.
Coverity issue: 344981, 344991, 345000, 345002, 345006, 345024
Fixes:
277310027965 ("raw/ntb: introduce NTB raw device driver")
Cc: stable@dpdk.org
Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>
ntb_attr_set(struct rte_rawdev *dev, const char *attr_name,
uint64_t attr_value)
{
ntb_attr_set(struct rte_rawdev *dev, const char *attr_name,
uint64_t attr_value)
{
- struct ntb_hw *hw = dev->dev_private;
- int index = 0;
+ struct ntb_hw *hw;
+ int index;
if (dev == NULL || attr_name == NULL) {
NTB_LOG(ERR, "Invalid arguments for setting attributes");
return -EINVAL;
}
if (dev == NULL || attr_name == NULL) {
NTB_LOG(ERR, "Invalid arguments for setting attributes");
return -EINVAL;
}
+ hw = dev->dev_private;
+
if (!strncmp(attr_name, NTB_SPAD_USER, NTB_SPAD_USER_LEN)) {
if (hw->ntb_ops->spad_write == NULL)
return -ENOTSUP;
if (!strncmp(attr_name, NTB_SPAD_USER, NTB_SPAD_USER_LEN)) {
if (hw->ntb_ops->spad_write == NULL)
return -ENOTSUP;
ntb_attr_get(struct rte_rawdev *dev, const char *attr_name,
uint64_t *attr_value)
{
ntb_attr_get(struct rte_rawdev *dev, const char *attr_name,
uint64_t *attr_value)
{
- struct ntb_hw *hw = dev->dev_private;
- int index = 0;
+ struct ntb_hw *hw;
+ int index;
if (dev == NULL || attr_name == NULL || attr_value == NULL) {
NTB_LOG(ERR, "Invalid arguments for getting attributes");
return -EINVAL;
}
if (dev == NULL || attr_name == NULL || attr_value == NULL) {
NTB_LOG(ERR, "Invalid arguments for getting attributes");
return -EINVAL;
}
+ hw = dev->dev_private;
+
if (!strncmp(attr_name, NTB_TOPO_NAME, NTB_ATTR_NAME_LEN)) {
*attr_value = hw->topo;
NTB_LOG(INFO, "Attribute (%s) Value (%" PRIu64 ")",
if (!strncmp(attr_name, NTB_TOPO_NAME, NTB_ATTR_NAME_LEN)) {
*attr_value = hw->topo;
NTB_LOG(INFO, "Attribute (%s) Value (%" PRIu64 ")",
if (pci_dev == NULL) {
NTB_LOG(ERR, "Invalid pci_dev.");
if (pci_dev == NULL) {
NTB_LOG(ERR, "Invalid pci_dev.");
}
memset(name, 0, sizeof(name));
}
memset(name, 0, sizeof(name));
socket_id);
if (rawdev == NULL) {
NTB_LOG(ERR, "Unable to allocate rawdev.");
socket_id);
if (rawdev == NULL) {
NTB_LOG(ERR, "Unable to allocate rawdev.");
}
rawdev->dev_ops = &ntb_ops;
}
rawdev->dev_ops = &ntb_ops;
rte_rawdev_pmd_release(rawdev);
return ret;
rte_rawdev_pmd_release(rawdev);
return ret;