notify_inotify: Add a NULL check
authorVolker Lendecke <vl@samba.org>
Mon, 27 Oct 2014 13:07:03 +0000 (13:07 +0000)
committerJeremy Allison <jra@samba.org>
Tue, 9 Dec 2014 03:12:08 +0000 (04:12 +0100)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/notify_inotify.c

index 2425bb4a5bc1b261106cb7f49652b8a66c332b30..56f49410661cf2586000bdac7326909bb25d6b43 100644 (file)
@@ -253,6 +253,7 @@ static void inotify_handler(struct tevent_context *ev, struct tevent_fd *fde,
 static NTSTATUS inotify_setup(struct sys_notify_context *ctx)
 {
        struct inotify_private *in;
+       struct tevent_fd *fde;
 
        in = talloc(ctx, struct inotify_private);
        NT_STATUS_HAVE_NO_MEMORY(in);
@@ -269,7 +270,13 @@ static NTSTATUS inotify_setup(struct sys_notify_context *ctx)
        talloc_set_destructor(in, inotify_destructor);
 
        /* add a event waiting for the inotify fd to be readable */
-       tevent_add_fd(ctx->ev, in, in->fd, TEVENT_FD_READ, inotify_handler, in);
+       fde = tevent_add_fd(ctx->ev, in, in->fd, TEVENT_FD_READ,
+                           inotify_handler, in);
+       if (fde == NULL) {
+               ctx->private_data = NULL;
+               TALLOC_FREE(in);
+               return NT_STATUS_NO_MEMORY;
+       }
 
        return NT_STATUS_OK;
 }