DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] raw/ntb: fix null pointer dereference
@ 2019-08-05  5:02 Xiaoyun Li
  2019-08-05  5:50 ` Ye Xiaolong
  0 siblings, 1 reply; 3+ messages in thread
From: Xiaoyun Li @ 2019-08-05  5:02 UTC (permalink / raw)
  To: jingjing.wu; +Cc: dev, Xiaoyun Li, stable

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>
---
 drivers/raw/ntb/ntb.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/raw/ntb/ntb.c b/drivers/raw/ntb/ntb.c
index 4ba2f3a38..bfecce1e4 100644
--- a/drivers/raw/ntb/ntb.c
+++ b/drivers/raw/ntb/ntb.c
@@ -447,14 +447,16 @@ static int
 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;
 	}
 
+	hw = dev->dev_private;
+
 	if (!strncmp(attr_name, NTB_SPAD_USER, NTB_SPAD_USER_LEN)) {
 		if (hw->ntb_ops->spad_write == NULL)
 			return -ENOTSUP;
@@ -475,14 +477,16 @@ static int
 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;
 	}
 
+	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 ")",
@@ -735,7 +739,7 @@ ntb_create(struct rte_pci_device *pci_dev, int socket_id)
 
 	if (pci_dev == NULL) {
 		NTB_LOG(ERR, "Invalid pci_dev.");
-		ret = -EINVAL;
+		return -EINVAL;
 	}
 
 	memset(name, 0, sizeof(name));
@@ -750,7 +754,7 @@ ntb_create(struct rte_pci_device *pci_dev, int socket_id)
 					 socket_id);
 	if (rawdev == NULL) {
 		NTB_LOG(ERR, "Unable to allocate rawdev.");
-		ret = -EINVAL;
+		return -EINVAL;
 	}
 
 	rawdev->dev_ops = &ntb_ops;
@@ -766,7 +770,7 @@ ntb_create(struct rte_pci_device *pci_dev, int socket_id)
 	return ret;
 
 fail:
-	if (rawdev)
+	if (rawdev != NULL)
 		rte_rawdev_pmd_release(rawdev);
 
 	return ret;
-- 
2.17.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] raw/ntb: fix null pointer dereference
  2019-08-05  5:02 [dpdk-dev] [PATCH] raw/ntb: fix null pointer dereference Xiaoyun Li
@ 2019-08-05  5:50 ` Ye Xiaolong
  2019-08-06  7:58   ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Ye Xiaolong @ 2019-08-05  5:50 UTC (permalink / raw)
  To: Xiaoyun Li; +Cc: jingjing.wu, dev, stable

On 08/05, Xiaoyun Li wrote:
>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>
>---
> drivers/raw/ntb/ntb.c | 18 +++++++++++-------
> 1 file changed, 11 insertions(+), 7 deletions(-)
>
>diff --git a/drivers/raw/ntb/ntb.c b/drivers/raw/ntb/ntb.c
>index 4ba2f3a38..bfecce1e4 100644
>--- a/drivers/raw/ntb/ntb.c
>+++ b/drivers/raw/ntb/ntb.c
>@@ -447,14 +447,16 @@ static int
> 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;
> 	}
> 
>+	hw = dev->dev_private;
>+
> 	if (!strncmp(attr_name, NTB_SPAD_USER, NTB_SPAD_USER_LEN)) {
> 		if (hw->ntb_ops->spad_write == NULL)
> 			return -ENOTSUP;
>@@ -475,14 +477,16 @@ static int
> 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;
> 	}
> 
>+	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 ")",
>@@ -735,7 +739,7 @@ ntb_create(struct rte_pci_device *pci_dev, int socket_id)
> 
> 	if (pci_dev == NULL) {
> 		NTB_LOG(ERR, "Invalid pci_dev.");
>-		ret = -EINVAL;
>+		return -EINVAL;
> 	}
> 
> 	memset(name, 0, sizeof(name));
>@@ -750,7 +754,7 @@ ntb_create(struct rte_pci_device *pci_dev, int socket_id)
> 					 socket_id);
> 	if (rawdev == NULL) {
> 		NTB_LOG(ERR, "Unable to allocate rawdev.");
>-		ret = -EINVAL;
>+		return -EINVAL;
> 	}
> 
> 	rawdev->dev_ops = &ntb_ops;
>@@ -766,7 +770,7 @@ ntb_create(struct rte_pci_device *pci_dev, int socket_id)
> 	return ret;
> 
> fail:
>-	if (rawdev)
>+	if (rawdev != NULL)
> 		rte_rawdev_pmd_release(rawdev);
> 
> 	return ret;
>-- 
>2.17.1
>

Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] raw/ntb: fix null pointer dereference
  2019-08-05  5:50 ` Ye Xiaolong
@ 2019-08-06  7:58   ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2019-08-06  7:58 UTC (permalink / raw)
  To: Xiaoyun Li; +Cc: dev, Ye Xiaolong, jingjing.wu, stable

05/08/2019 07:50, Ye Xiaolong:
> On 08/05, Xiaoyun Li wrote:
> >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>

Applied, thanks



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-08-06  7:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-05  5:02 [dpdk-dev] [PATCH] raw/ntb: fix null pointer dereference Xiaoyun Li
2019-08-05  5:50 ` Ye Xiaolong
2019-08-06  7:58   ` Thomas Monjalon

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).