Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vinput: Fix multiple issue #258

Merged
merged 3 commits into from
May 14, 2024
Merged

vinput: Fix multiple issue #258

merged 3 commits into from
May 14, 2024

Conversation

visitorckw
Copy link
Contributor

@visitorckw visitorckw commented May 8, 2024

Fix multiple issues for vinput module:

  1. Removes redundant memset calls that were unnecessary since memory allocated with kzalloc is already zeroed due to the __GFP_ZERO gfp flag.
  2. Fixes a NULL pointer dereference caused by failed kzalloc allocation. It adds a check for the return value of kzalloc and handles failed allocations by printing an error message and returning ERR_PTR(-ENOMEM).
  3. Corrects the handling of failures in raw_copy_to_user() in vinput_read(). Previously, the function would modify '*offset' incorrectly on raw_copy_to_user() failure. Fix this behavior by changing count = -EFAULT to return -EFAULT instead.

Remove redundant memset calls as memory allocated with kzalloc is
already zeroed due to the presence of the __GFP_ZERO gfp flag.
When kzalloc fails to allocate memory and returns NULL, it leads to a
NULL pointer dereference error later on. Add a check for the return
value of kzalloc. When kzalloc fails to allocate memory, it prints an
error message and returns ERR_PTR(-ENOMEM).
When raw_copy_to_user() failed in vinput_read(), the function would set
'count' to -EFAULT and then subtract EFAULT from '*offset'. However,
modifying '*offset' on raw_copy_to_user() failure was incorrect. Fix
this behavior by changing count = -EFAULT to return -EFAULT.
@jserv
Copy link
Contributor

jserv commented May 9, 2024

Can you check #52 ?

@linD026
Copy link
Collaborator

linD026 commented May 9, 2024

Looks good to me.

@jserv jserv changed the title vinput: Fix multiple issues for vinput module vinput: Fix multiple issue May 9, 2024
@visitorckw
Copy link
Contributor Author

Can you check #52 ?

I can spend some time understanding try_module_get and put_module_get and try to resolve this issue.

@jserv jserv merged commit e1eced6 into sysprog21:master May 14, 2024
1 check passed
@jserv
Copy link
Contributor

jserv commented May 14, 2024

Thank @visitorckw for contributing!

@visitorckw visitorckw deleted the fix-vinput branch May 15, 2024 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants