}
 }
 
-static void __invalidate_snapshot(struct dm_snapshot *s,
-                               struct pending_exception *pe, int err)
+static void __invalidate_snapshot(struct dm_snapshot *s, int err)
 {
        if (!s->valid)
                return;
        else if (err == -ENOMEM)
                DMERR("Invalidating snapshot: Unable to allocate exception.");
 
-       if (pe)
-               remove_exception(&pe->e);
-
        if (s->store.drop_snapshot)
                s->store.drop_snapshot(&s->store);
 
        if (!success) {
                /* Read/write error - snapshot is unusable */
                down_write(&s->lock);
-               __invalidate_snapshot(s, pe, -EIO);
+               __invalidate_snapshot(s, -EIO);
                error = 1;
                goto out;
        }
        e = alloc_exception();
        if (!e) {
                down_write(&s->lock);
-               __invalidate_snapshot(s, pe, -ENOMEM);
+               __invalidate_snapshot(s, -ENOMEM);
                error = 1;
                goto out;
        }
         * in-flight exception from the list.
         */
        insert_exception(&s->complete, e);
-       remove_exception(&pe->e);
 
  out:
+       remove_exception(&pe->e);
        snapshot_bios = bio_list_get(&pe->snapshot_bios);
        origin_bios = put_pending_exception(pe);
 
        if (bio_rw(bio) == WRITE) {
                pe = __find_pending_exception(s, bio);
                if (!pe) {
-                       __invalidate_snapshot(s, pe, -ENOMEM);
+                       __invalidate_snapshot(s, -ENOMEM);
                        r = -EIO;
                        goto out_unlock;
                }
 
                pe = __find_pending_exception(snap, bio);
                if (!pe) {
-                       __invalidate_snapshot(snap, pe, -ENOMEM);
+                       __invalidate_snapshot(snap, -ENOMEM);
                        goto next_snapshot;
                }