[v3,10/10] bus/vdev: check result of rte_vdev_device_name

Message ID 20230120044140.95975-11-okaya@kernel.org (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series codeql fixes for various subsystems |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-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

Commit Message

Sinan Kaya Jan. 20, 2023, 4:41 a.m. UTC
  From: Sinan Kaya <okaya@kernel.org>

In rte_eth_vdev_allocate result of call to rte_vdev_device_name is
dereferenced here and may be null.

Signed-off-by: Sinan Kaya <okaya@kernel.org>
---
 lib/ethdev/ethdev_vdev.h | 2 ++
 1 file changed, 2 insertions(+)
  

Comments

Stephen Hemminger Jan. 20, 2023, 4:47 p.m. UTC | #1
On Thu, 19 Jan 2023 23:41:40 -0500
okaya@kernel.org wrote:

> diff --git a/lib/ethdev/ethdev_vdev.h b/lib/ethdev/ethdev_vdev.h
> index 364f140f91..6d94a65d97 100644
> --- a/lib/ethdev/ethdev_vdev.h
> +++ b/lib/ethdev/ethdev_vdev.h
> @@ -34,6 +34,8 @@ rte_eth_vdev_allocate(struct rte_vdev_device *dev, size_t private_data_size)
>  {
>  	struct rte_eth_dev *eth_dev;
>  	const char *name = rte_vdev_device_name(dev);
> +	if (name == NULL)
> +		return NULL;


Please add a blank line after declarations and before code.
For some reason the DPDK version of checkpatch suppresses this warning.
  
Thomas Monjalon Jan. 22, 2023, 8:51 p.m. UTC | #2
20/01/2023 17:47, Stephen Hemminger:
> On Thu, 19 Jan 2023 23:41:40 -0500
> okaya@kernel.org wrote:
> 
> > diff --git a/lib/ethdev/ethdev_vdev.h b/lib/ethdev/ethdev_vdev.h
> > index 364f140f91..6d94a65d97 100644
> > --- a/lib/ethdev/ethdev_vdev.h
> > +++ b/lib/ethdev/ethdev_vdev.h
> > @@ -34,6 +34,8 @@ rte_eth_vdev_allocate(struct rte_vdev_device *dev, size_t private_data_size)
> >  {
> >  	struct rte_eth_dev *eth_dev;
> >  	const char *name = rte_vdev_device_name(dev);
> > +	if (name == NULL)
> > +		return NULL;
> 
> Please add a blank line after declarations and before code.
> For some reason the DPDK version of checkpatch suppresses this warning.

The check of "name" is related to the line above,
so I don't think we should insert a blank line.
  
Sinan Kaya Feb. 6, 2023, 4:01 p.m. UTC | #3
On Sun, 2023-01-22 at 21:51 +0100, Thomas Monjalon wrote:
> 20/01/2023 17:47, Stephen Hemminger:
> > On Thu, 19 Jan 2023 23:41:40 -0500
> > okaya@kernel.org wrote:
> > 
> > > diff --git a/lib/ethdev/ethdev_vdev.h b/lib/ethdev/ethdev_vdev.h
> > > index 364f140f91..6d94a65d97 100644
> > > --- a/lib/ethdev/ethdev_vdev.h
> > > +++ b/lib/ethdev/ethdev_vdev.h
> > > @@ -34,6 +34,8 @@ rte_eth_vdev_allocate(struct rte_vdev_device
> > > *dev, size_t private_data_size)
> > >  {
> > >  	struct rte_eth_dev *eth_dev;
> > >  	const char *name = rte_vdev_device_name(dev);
> > > +	if (name == NULL)
> > > +		return NULL;
> > 
> > Please add a blank line after declarations and before code.
> > For some reason the DPDK version of checkpatch suppresses this
> > warning.
> 
> The check of "name" is related to the line above,
> so I don't think we should insert a blank line.
> 
> 

While I'm waiting for maintainer feedback, let me know which
way I should go. I can update this for next rev.
  
Thomas Monjalon Feb. 6, 2023, 6:46 p.m. UTC | #4
06/02/2023 17:01, Sinan Kaya:
> On Sun, 2023-01-22 at 21:51 +0100, Thomas Monjalon wrote:
> > 20/01/2023 17:47, Stephen Hemminger:
> > > On Thu, 19 Jan 2023 23:41:40 -0500
> > > okaya@kernel.org wrote:
> > > 
> > > > diff --git a/lib/ethdev/ethdev_vdev.h b/lib/ethdev/ethdev_vdev.h
> > > > index 364f140f91..6d94a65d97 100644
> > > > --- a/lib/ethdev/ethdev_vdev.h
> > > > +++ b/lib/ethdev/ethdev_vdev.h
> > > > @@ -34,6 +34,8 @@ rte_eth_vdev_allocate(struct rte_vdev_device
> > > > *dev, size_t private_data_size)
> > > >  {
> > > >  	struct rte_eth_dev *eth_dev;
> > > >  	const char *name = rte_vdev_device_name(dev);
> > > > +	if (name == NULL)
> > > > +		return NULL;
> > > 
> > > Please add a blank line after declarations and before code.
> > > For some reason the DPDK version of checkpatch suppresses this
> > > warning.
> > 
> > The check of "name" is related to the line above,
> > so I don't think we should insert a blank line.
> 
> While I'm waiting for maintainer feedback, let me know which
> way I should go. I can update this for next rev.

It's just a matter of taste, not a big deal.
I think you can keep it as-is.
  

Patch

diff --git a/lib/ethdev/ethdev_vdev.h b/lib/ethdev/ethdev_vdev.h
index 364f140f91..6d94a65d97 100644
--- a/lib/ethdev/ethdev_vdev.h
+++ b/lib/ethdev/ethdev_vdev.h
@@ -34,6 +34,8 @@  rte_eth_vdev_allocate(struct rte_vdev_device *dev, size_t private_data_size)
 {
 	struct rte_eth_dev *eth_dev;
 	const char *name = rte_vdev_device_name(dev);
+	if (name == NULL)
+		return NULL;
 
 	eth_dev = rte_eth_dev_allocate(name);
 	if (!eth_dev)