diff mbox

[OpenWrt-Devel,netifd,07/16] proto-shell: Fix possible segfault

Message ID 1454320590-20710-7-git-send-email-dedeckeh@gmail.com
State Accepted
Headers show

Commit Message

Hans Dedecker Feb. 1, 2016, 9:56 a.m. UTC
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
---
 proto-shell.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox

Patch

diff --git a/proto-shell.c b/proto-shell.c
index 8a3ff69..25dec00 100644
--- a/proto-shell.c
+++ b/proto-shell.c
@@ -708,6 +708,8 @@  proto_shell_add_host_dependency(struct proto_shell_state *state, struct blob_att
 		return UBUS_STATUS_PERMISSION_DENIED;
 
 	dep = calloc(1, sizeof(*dep) + strlen(ifname) + 1);
+	if (!dep)
+		return UBUS_STATUS_UNKNOWN_ERROR;
 
 	if (!host[0] && ifname[0]) {
 		dep->any = true;
@@ -834,6 +836,9 @@  proto_shell_attach(const struct proto_handler *h, struct interface *iface,
 	struct proto_shell_state *state;
 
 	state = calloc(1, sizeof(*state));
+	if (!state)
+		return NULL;
+
 	INIT_LIST_HEAD(&state->deps);
 
 	state->config = malloc(blob_pad_len(attr));