Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+4
+4
tools/firewire/nosy-dump.c
··· 150 150 151 151 /* we put the ack in the subaction struct for easy access. */ 152 152 sa = malloc(sizeof *sa - sizeof sa->packet + length); 153 + if (!sa) 154 + exit(EXIT_FAILURE); 153 155 sa->ack = data[length / 4 - 1]; 154 156 sa->length = length; 155 157 memcpy(&sa->packet, data, length); ··· 182 180 } 183 181 184 182 t = malloc(sizeof *t); 183 + if (!t) 184 + exit(EXIT_FAILURE); 185 185 t->request_node = request_node; 186 186 t->response_node = response_node; 187 187 t->tlabel = tlabel;