Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit effbeaa9 authored by Guru Das Srinagesh's avatar Guru Das Srinagesh
Browse files

power: battery: Fix error handling in votables' creation



The error handling path for failed calls to create_votable() currently
transfers program execution control to the label destroy_votable, where
the return code of the create_votable() call is directly passed to
destroy_votable(), ostensibly for cleanup.

Upon closer inspection, it is observed that the create_votable()
function cleans up after itself in the case of errors in all of its
intermediate steps before returning an error code. The error code is
essentially a negative integer returned as a typecasted pointer which,
when directly passed to destroy_votable(), will surely cause a crash at
the list_del() step within, as that function doesn't really do thorough
input sanitization.

Fix this by overwriting the return code of calls to create_votable()
with NULL in the case of error, before invoking destroy_votable(). This
prevents a crash because there is a NULL check at the very beginning of
that function.

Change-Id: Ic923051319c4af89b22752e6bea4afbf0111d777
Signed-off-by: default avatarGuru Das Srinagesh <gurus@codeaurora.org>
parent 871eac76
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment