[dpdk-dev] eal: Fix wrong error checking of rte_eal_parse_devargs_str()

Message ID 1465961209-28309-1-git-send-email-mukawa@igel.co.jp (mailing list archive)
State Changes Requested, archived
Headers

Commit Message

Tetsuya Mukawa June 15, 2016, 3:26 a.m. UTC
  Currently, a return value of strdup() isn't checked correctly.
The patch fixes it.

Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
---
 lib/librte_eal/common/eal_common_devargs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

David Marchand June 15, 2016, 2:48 p.m. UTC | #1
On Wed, Jun 15, 2016 at 5:26 AM, Tetsuya Mukawa <mukawa@igel.co.jp> wrote:
> Currently, a return value of strdup() isn't checked correctly.
> The patch fixes it.
>
> Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>

Idem, the title does not need the function name to describe what is going wrong.

This might deserve a fixline, I traced this to 0fe11ec592b2 ("eal: add
vdev init and uninit").

> ---
>  lib/librte_eal/common/eal_common_devargs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
> index 2bfe54a..e403717 100644
> --- a/lib/librte_eal/common/eal_common_devargs.c
> +++ b/lib/librte_eal/common/eal_common_devargs.c
> @@ -58,7 +58,7 @@ rte_eal_parse_devargs_str(const char *devargs_str,
>                 return -1;
>
>         *drvname = strdup(devargs_str);
> -       if (drvname == NULL)
> +       if (*drvname == NULL)
>                 return -1;
>
>         /* set the first ',' to '\0' to split name and arguments */
> --
> 2.7.4
>
  
Tetsuya Mukawa June 16, 2016, 2:03 a.m. UTC | #2
On 2016/06/15 23:48, David Marchand wrote:
> On Wed, Jun 15, 2016 at 5:26 AM, Tetsuya Mukawa <mukawa@igel.co.jp> wrote:
>> Currently, a return value of strdup() isn't checked correctly.
>> The patch fixes it.
>>
>> Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
> 
> Idem, the title does not need the function name to describe what is going wrong.
> 
> This might deserve a fixline, I traced this to 0fe11ec592b2 ("eal: add
> vdev init and uninit").

Will add it.

Thanks,
Tetsuya
  

Patch

diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index 2bfe54a..e403717 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -58,7 +58,7 @@  rte_eal_parse_devargs_str(const char *devargs_str,
 		return -1;
 
 	*drvname = strdup(devargs_str);
-	if (drvname == NULL)
+	if (*drvname == NULL)
 		return -1;
 
 	/* set the first ',' to '\0' to split name and arguments */