diff mbox series

[1/2] libkmod-module: check "new_from_name" return value in get_builtin

Message ID 20210608062923.94017-1-ykaliuta@redhat.com (mailing list archive)
State New, archived
Headers show
Series Fix a couple of potential problem (static analysis) | expand

Commit Message

Yauheni Kaliuta June 8, 2021, 6:29 a.m. UTC
kmod_module_new_from_name() may fail and return error value. It is
handled properly across the code, but in this particular place the
check is missing.

Signed-off-by: Yauheni Kaliuta <ykaliuta@redhat.com>
---
 libkmod/libkmod-module.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Lucas De Marchi June 9, 2021, 5:22 p.m. UTC | #1
On Tue, Jun 08, 2021 at 09:29:22AM +0300, Yauheni Kaliuta wrote:
>kmod_module_new_from_name() may fail and return error value. It is
>handled properly across the code, but in this particular place the
>check is missing.
>
>Signed-off-by: Yauheni Kaliuta <ykaliuta@redhat.com>

applied, thanks

Lucas De Marchi

>---
> libkmod/libkmod-module.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
>diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
>index b6320cc87e80..6e0ff1a99604 100644
>--- a/libkmod/libkmod-module.c
>+++ b/libkmod/libkmod-module.c
>@@ -2912,7 +2912,10 @@ int kmod_module_get_builtin(struct kmod_ctx *ctx, struct kmod_list **list)
> 			goto fail;
> 		}
>
>-		kmod_module_new_from_name(ctx, modname, &mod);
>+		err = kmod_module_new_from_name(ctx, modname, &mod);
>+		if (err < 0)
>+			goto fail;
>+
> 		kmod_module_set_builtin(mod, true);
>
> 		*list = kmod_list_append(*list, mod);
>-- 
>2.31.1
>
diff mbox series

Patch

diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index b6320cc87e80..6e0ff1a99604 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
@@ -2912,7 +2912,10 @@  int kmod_module_get_builtin(struct kmod_ctx *ctx, struct kmod_list **list)
 			goto fail;
 		}
 
-		kmod_module_new_from_name(ctx, modname, &mod);
+		err = kmod_module_new_from_name(ctx, modname, &mod);
+		if (err < 0)
+			goto fail;
+
 		kmod_module_set_builtin(mod, true);
 
 		*list = kmod_list_append(*list, mod);