-
Notifications
You must be signed in to change notification settings - Fork 79
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
For linux msm/valgrind fixes #86
For linux msm/valgrind fixes #86
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice cleanup.. very much needed !
util.c
Outdated
return NULL; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an if/else statement would seem slightly better here. nitpicking..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if/else looks clumsy, the function has the shape "if error early exit, if error early exit, else strdup() and return". But the second "error" isn't really an error, so it looks better turning this into a single-exit.
Thanks.
@@ -492,7 +492,8 @@ int sahara_run(struct qdl_device *qdl, char *img_arr[], bool single_image, | |||
} | |||
} | |||
|
|||
close(ramdump_dir); | |||
if (ramdump_dir >= 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hygine spelling in the commit message
Every time the USB code attempts to identify and possibly open the EDL USB device, the libusb device descriptor-object is leaked. While at it, also introduce qdl_close() to clean up the overall state, in order to approach not leaking memory in a clean QDL run. Signed-off-by: Bjorn Andersson <[email protected]>
Continuing the journey to make QDL not leak any memory on a successful run, introduce operations to free the program and patch objects on exit. Signed-off-by: Bjorn Andersson <[email protected]>
For each <program/> entry int he list, a scratch buffer of "max payload size" is allocated, and lost. Free this memory instead. Signed-off-by: Bjorn Andersson <[email protected]>
The XML parsing helpers turns libxml strings into standard C-types and leaks the libxml memory. Fix this by freeing the libxml strings once they are accessed. Signed-off-by: Bjorn Andersson <[email protected]>
Valgrind correctly reports that the write of 0x30 bytes accesses uninitialized stack space. Pad the Sahara HELLO request and response with the expected "reserved" entries to reach the defined 0x30 bytes to avoid sending random stack content to the device. Signed-off-by: Bjorn Andersson <[email protected]>
In the event that no ramdump_path is provided to sahara_run() the ramdump_dir will remain -1. For good hygiene avoid calling close() on this invalid file descriptor. Signed-off-by: Bjorn Andersson <[email protected]>
In a few places in firehose.c the memory returned from xmlGetProp() is leaked. Avoid this by freeing it. Signed-off-by: Bjorn Andersson <[email protected]>
5141e5f
to
1a6f38e
Compare
Attempting to debug a bug report with Valgrind highlighted a number of issues in the implementation. The issue turned out to exist elsewhere, but let's resolve all the reported issues, to make Valgrind more useful in detecting future issues - and to improve the quality of the code.