[v3,10/10] bus/vdev: check result of rte_vdev_device_name
Checks
Commit Message
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
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.
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.
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.
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.
@@ -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)