On Wed, Jan 16, 2013 at 12:02 PM, Dave Reisner <[email protected]> wrote:
> Trust this value, instead of injecting our own, as this could be
> something as simple as ENOENT, rather than an alarming ENOMEM.
> ---
>  libkmod/libkmod.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c
> index b3e1d6b..0d9cd80 100644
> --- a/libkmod/libkmod.c
> +++ b/libkmod/libkmod.c
> @@ -816,7 +816,7 @@ KMOD_EXPORT int kmod_load_resources(struct kmod_ctx *ctx)
>
>  fail:
>         kmod_unload_resources(ctx);
> -       return -ENOMEM;
> +       return -errno;
>  }

Does this actually work?  if index_mm_open() fails it may had passed
through munmap(), close() and free() before returning to
kmod_load_resources(). The first 2 can touch errno. Worse than that,
we also "goto fail" in index_mm_open() if the checks for magic or
version failed, in which case errno will not be set and we will
incorrectly return that this function succeeded.

return -ENOMEM there maybe is not a good choice, but changing it to
may actually introduce bugs. Maybe -EINVAL or -1 would be a better
choice. Thoughts?


Lucas De Marchi
--
To unsubscribe from this list: send the line "unsubscribe linux-modules" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to