Message ID | 20190610101742.27518-1-colin.king@canonical.com |
---|---|
State | Accepted |
Headers | show |
Series |
|
Related | show |
On 2019-06-10 3:17 a.m., Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > The null pointer check is currently incorrect; if ptr is null then > we currently have a null pointer dereference. The check should be > for a null ptr rather rather than the contents of the object being > pointed to being non-zero. > > Addresses-Coverity: ("Dereference null pointer") > Fixes: cbf322756c13 ("src/lib: add module probing helper functions") > Signed-off-by: Colin Ian King <colin.king@canonical.com> > --- > src/lib/src/fwts_modprobe.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/lib/src/fwts_modprobe.c b/src/lib/src/fwts_modprobe.c > index 05871f2c..a05a581f 100644 > --- a/src/lib/src/fwts_modprobe.c > +++ b/src/lib/src/fwts_modprobe.c > @@ -131,7 +131,7 @@ int fwts_module_loaded(fwts_framework *fw, const char *module, bool *loaded) > while (fgets(buffer, sizeof(buffer) - 1, fp) != NULL) { > char *ptr = strchr(buffer, ' '); > > - if (*ptr) > + if (ptr) > *ptr = '\0'; > > if (!strcmp(buffer, module)) { > Acked-by: Alex Hung <alex.hung@canonical.com>
On 6/10/19 6:17 PM, Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > The null pointer check is currently incorrect; if ptr is null then > we currently have a null pointer dereference. The check should be > for a null ptr rather rather than the contents of the object being > pointed to being non-zero. > > Addresses-Coverity: ("Dereference null pointer") > Fixes: cbf322756c13 ("src/lib: add module probing helper functions") > Signed-off-by: Colin Ian King <colin.king@canonical.com> > --- > src/lib/src/fwts_modprobe.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/lib/src/fwts_modprobe.c b/src/lib/src/fwts_modprobe.c > index 05871f2c..a05a581f 100644 > --- a/src/lib/src/fwts_modprobe.c > +++ b/src/lib/src/fwts_modprobe.c > @@ -131,7 +131,7 @@ int fwts_module_loaded(fwts_framework *fw, const char *module, bool *loaded) > while (fgets(buffer, sizeof(buffer) - 1, fp) != NULL) { > char *ptr = strchr(buffer, ' '); > > - if (*ptr) > + if (ptr) > *ptr = '\0'; > > if (!strcmp(buffer, module)) { Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff --git a/src/lib/src/fwts_modprobe.c b/src/lib/src/fwts_modprobe.c index 05871f2c..a05a581f 100644 --- a/src/lib/src/fwts_modprobe.c +++ b/src/lib/src/fwts_modprobe.c @@ -131,7 +131,7 @@ int fwts_module_loaded(fwts_framework *fw, const char *module, bool *loaded) while (fgets(buffer, sizeof(buffer) - 1, fp) != NULL) { char *ptr = strchr(buffer, ' '); - if (*ptr) + if (ptr) *ptr = '\0'; if (!strcmp(buffer, module)) {