eventdev: check input parameter for dump op

Message ID 20201101203644.1697-1-david.marchand@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: Jerin Jacob
Headers
Series eventdev: check input parameter for dump op |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/travis-robot success Travis build: passed
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS

Commit Message

David Marchand Nov. 1, 2020, 8:36 p.m. UTC
  Rather than have drivers check for this, let's ensure the passed FILE *
is not NULL.

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 lib/librte_eventdev/rte_eventdev.c | 2 ++
 1 file changed, 2 insertions(+)
  

Comments

Timothy McDaniel Nov. 1, 2020, 8:52 p.m. UTC | #1
> -----Original Message-----
> From: David Marchand <david.marchand@redhat.com>
> Sent: Sunday, November 1, 2020 2:37 PM
> To: dev@dpdk.org
> Cc: McDaniel, Timothy <timothy.mcdaniel@intel.com>; Jerin Jacob
> <jerinj@marvell.com>
> Subject: [PATCH] eventdev: check input parameter for dump op
> 
> Rather than have drivers check for this, let's ensure the passed FILE *
> is not NULL.
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
>  lib/librte_eventdev/rte_eventdev.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/lib/librte_eventdev/rte_eventdev.c
> b/lib/librte_eventdev/rte_eventdev.c
> index 994bd1eaa9..afbadc535b 100644
> --- a/lib/librte_eventdev/rte_eventdev.c
> +++ b/lib/librte_eventdev/rte_eventdev.c
> @@ -1153,6 +1153,8 @@ rte_event_dev_dump(uint8_t dev_id, FILE *f)
>  	RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
>  	dev = &rte_eventdevs[dev_id];
>  	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dump, -ENOTSUP);
> +	if (f == NULL)
> +		return -EINVAL;
> 
>  	(*dev->dev_ops->dump)(dev, f);
>  	return 0;
> --
> 2.23.0

Looks good to me.

Reviewed-by: Timothy McDaniel <timothy.mcdaniel@intel.com>
  
Jerin Jacob Nov. 2, 2020, 2:04 p.m. UTC | #2
On Mon, Nov 2, 2020 at 2:22 AM McDaniel, Timothy
<timothy.mcdaniel@intel.com> wrote:
>
>
>
> > -----Original Message-----
> > From: David Marchand <david.marchand@redhat.com>
> > Sent: Sunday, November 1, 2020 2:37 PM
> > To: dev@dpdk.org
> > Cc: McDaniel, Timothy <timothy.mcdaniel@intel.com>; Jerin Jacob
> > <jerinj@marvell.com>
> > Subject: [PATCH] eventdev: check input parameter for dump op
> >
> > Rather than have drivers check for this, let's ensure the passed FILE *
> > is not NULL.
> >
> > Signed-off-by: David Marchand <david.marchand@redhat.com>

Applied to dpdk-next-eventdev/for-main. Thanks.



> > ---
> >  lib/librte_eventdev/rte_eventdev.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/lib/librte_eventdev/rte_eventdev.c
> > b/lib/librte_eventdev/rte_eventdev.c
> > index 994bd1eaa9..afbadc535b 100644
> > --- a/lib/librte_eventdev/rte_eventdev.c
> > +++ b/lib/librte_eventdev/rte_eventdev.c
> > @@ -1153,6 +1153,8 @@ rte_event_dev_dump(uint8_t dev_id, FILE *f)
> >       RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
> >       dev = &rte_eventdevs[dev_id];
> >       RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dump, -ENOTSUP);
> > +     if (f == NULL)
> > +             return -EINVAL;
> >
> >       (*dev->dev_ops->dump)(dev, f);
> >       return 0;
> > --
> > 2.23.0
>
> Looks good to me.
>
> Reviewed-by: Timothy McDaniel <timothy.mcdaniel@intel.com>
  

Patch

diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c
index 994bd1eaa9..afbadc535b 100644
--- a/lib/librte_eventdev/rte_eventdev.c
+++ b/lib/librte_eventdev/rte_eventdev.c
@@ -1153,6 +1153,8 @@  rte_event_dev_dump(uint8_t dev_id, FILE *f)
 	RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
 	dev = &rte_eventdevs[dev_id];
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dump, -ENOTSUP);
+	if (f == NULL)
+		return -EINVAL;
 
 	(*dev->dev_ops->dump)(dev, f);
 	return 0;