[v2] net/memif: remove pointer deference before null check

Message ID tencent_7F46CC1FCFE7295F8495CEF137EAC8AE0806@qq.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series [v2] net/memif: remove pointer deference before null check |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS

Commit Message

Weiguo Li Feb. 9, 2022, 7:39 a.m. UTC
  There are duplicates of assignment here, the one before null check
may cause a null pointer deference, so remove the previous one.

Fixes: 09c7e63a71f9 ("net/memif: introduce memory interface PMD")

Signed-off-by: Weiguo Li <liwg06@foxmail.com>
---
v2:
* fix typo
---
 drivers/net/memif/memif_socket.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
  

Comments

Ferruh Yigit Feb. 9, 2022, 1:56 p.m. UTC | #1
On 2/9/2022 7:39 AM, Weiguo Li wrote:
> There are duplicates of assignment here, the one before null check
> may cause a null pointer deference, so remove the previous one.
> 
> Fixes: 09c7e63a71f9 ("net/memif: introduce memory interface PMD")
> 

Cc: stable@dpdk.org

> Signed-off-by: Weiguo Li <liwg06@foxmail.com>

Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
  
Ferruh Yigit Feb. 9, 2022, 5:51 p.m. UTC | #2
On 2/9/2022 1:56 PM, Ferruh Yigit wrote:
> On 2/9/2022 7:39 AM, Weiguo Li wrote:
>> There are duplicates of assignment here, the one before null check
>> may cause a null pointer deference, so remove the previous one.
>>
>> Fixes: 09c7e63a71f9 ("net/memif: introduce memory interface PMD")
>>
> 
> Cc: stable@dpdk.org
> 
>> Signed-off-by: Weiguo Li <liwg06@foxmail.com>
> 
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied to dpdk-next-net/main, thanks.
  

Patch

diff --git a/drivers/net/memif/memif_socket.c b/drivers/net/memif/memif_socket.c
index 42f48a68a1..7886644412 100644
--- a/drivers/net/memif/memif_socket.c
+++ b/drivers/net/memif/memif_socket.c
@@ -402,11 +402,10 @@  memif_msg_enq_init(struct rte_eth_dev *dev)
 {
 	struct pmd_internals *pmd = dev->data->dev_private;
 	struct memif_msg_queue_elt *e = memif_msg_enq(pmd->cc);
-	memif_msg_init_t *i = &e->msg.init;
+	memif_msg_init_t *i;
 
 	if (e == NULL)
 		return -1;
-
 	i = &e->msg.init;
 	e->msg.type = MEMIF_MSG_TYPE_INIT;
 	i->version = MEMIF_VERSION;