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 |
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 --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);
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(-)