[dpdk-dev] eal: fix check for default plugin directory

Message ID 20171106135800.12350-1-bruce.richardson@intel.com (mailing list archive)
State Accepted, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Bruce Richardson Nov. 6, 2017, 1:58 p.m. UTC
  The check for the existence of the default plugin directory calls stat
using an incorrect variable, which will cause a NULL pointer dereference
error.

Coverity issue: 198440
Fixes: d6a4399cdfc9 ("eal: avoid error for non-existent default PMD path")

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/librte_eal/common/eal_common_options.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Aaron Conole Nov. 6, 2017, 8:36 p.m. UTC | #1
Bruce Richardson <bruce.richardson@intel.com> writes:

> The check for the existence of the default plugin directory calls stat
> using an incorrect variable, which will cause a NULL pointer dereference
> error.
>
> Coverity issue: 198440
> Fixes: d6a4399cdfc9 ("eal: avoid error for non-existent default PMD path")
>
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---

Acked-by: Aaron Conole <aconole@redhat.com>

Glad I checked the list before going after this one. ;)
  
Thomas Monjalon Nov. 7, 2017, 12:23 a.m. UTC | #2
06/11/2017 21:36, Aaron Conole:
> Bruce Richardson <bruce.richardson@intel.com> writes:
> 
> > The check for the existence of the default plugin directory calls stat
> > using an incorrect variable, which will cause a NULL pointer dereference
> > error.
> >
> > Coverity issue: 198440
> > Fixes: d6a4399cdfc9 ("eal: avoid error for non-existent default PMD path")
> >
> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> 
> Acked-by: Aaron Conole <aconole@redhat.com>

Applied, thanks
  

Patch

diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index 450f2664a..996a03424 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -280,7 +280,7 @@  eal_plugins_init(void)
 	struct shared_driver *solib = NULL;
 	struct stat sb;
 
-	if (*default_solib_dir != '\0' && stat(solib->name, &sb) == 0 &&
+	if (*default_solib_dir != '\0' && stat(default_solib_dir, &sb) == 0 &&
 				S_ISDIR(sb.st_mode))
 		eal_plugin_add(default_solib_dir);