mirror of
https://github.com/team-infusion-developers/android_kernel_samsung_msm8976.git
synced 2024-11-07 04:09:21 +00:00
tools/firewire: nosy-dump: check for allocation failure
Behavior of null pointer dereference is undefined in the C language. Portably implement the desired behavior. Reported-by: Yang Yeping <yangyeping_666@hotmail.com> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
This commit is contained in:
parent
9489e9dcae
commit
6fa79bcaec
1 changed files with 4 additions and 0 deletions
|
@ -150,6 +150,8 @@ subaction_create(uint32_t *data, size_t length)
|
|||
|
||||
/* we put the ack in the subaction struct for easy access. */
|
||||
sa = malloc(sizeof *sa - sizeof sa->packet + length);
|
||||
if (!sa)
|
||||
exit(EXIT_FAILURE);
|
||||
sa->ack = data[length / 4 - 1];
|
||||
sa->length = length;
|
||||
memcpy(&sa->packet, data, length);
|
||||
|
@ -180,6 +182,8 @@ link_transaction_lookup(int request_node, int response_node, int tlabel)
|
|||
}
|
||||
|
||||
t = malloc(sizeof *t);
|
||||
if (!t)
|
||||
exit(EXIT_FAILURE);
|
||||
t->request_node = request_node;
|
||||
t->response_node = response_node;
|
||||
t->tlabel = tlabel;
|
||||
|
|
Loading…
Reference in a new issue