ceph: fix possible NULL pointer dereference
authorMariusz Kozlowski <mk@lab.zgora.pl>
Sat, 26 Mar 2011 18:29:34 +0000 (19:29 +0100)
committerSage Weil <sage@newdream.net>
Sat, 26 Mar 2011 20:41:20 +0000 (13:41 -0700)
This patch fixes 'event_work' dereference before it is checked for NULL.

Signed-off-by: Mariusz Kozlowski <mk@lab.zgora.pl>
Signed-off-by: Sage Weil <sage@newdream.net>
net/ceph/osd_client.c

index 02212ed50852eaa41b5d0c75c7f121b77f074ce3..b6776cb627cc23148adc18e1a76d054ee1f58648 100644 (file)
@@ -1602,11 +1602,11 @@ void handle_watch_notify(struct ceph_osd_client *osdc, struct ceph_msg *msg)
             cookie, ver, event);
        if (event) {
                event_work = kmalloc(sizeof(*event_work), GFP_NOIO);
-               INIT_WORK(&event_work->work, do_event_work);
                if (!event_work) {
                        dout("ERROR: could not allocate event_work\n");
                        goto done_err;
                }
+               INIT_WORK(&event_work->work, do_event_work);
                event_work->event = event;
                event_work->ver = ver;
                event_work->notify_id = notify_id;