video: adf: use rb_erase in adf_obj_destroy.
authorAlistair Strachan <alistair.strachan@imgtec.com>
Mon, 21 Apr 2014 20:09:23 +0000 (13:09 -0700)
committerJohn Stultz <john.stultz@linaro.org>
Tue, 16 Feb 2016 21:53:21 +0000 (13:53 -0800)
Not calling rb_erase() can cause slab corruption, as the rb_first() call
after kfree() in adf_obj_destroy() can return the same node twice unless
it is erased.

This problem was reproduced by unloading a kernel module that used the
adf framework *after* a vsync event was registered. A crash would occur
in rb_first(). (Just loading and immediately unloading the module without
the vsync event worked correctly.)

Change-Id: I9fa7cb5d7519691e38a281439844aa193da13d1b
Signed-off-by: Alistair Strachan <alistair.strachan@imgtec.com>
Cc: Jonathan Hamilton <jonathan.hamilton@imgtec.com>
Cc: Greg Hackmann <ghackmann@google.com>
drivers/video/adf/adf.c

index e6ef144136c223da1782707d7049754830670d7b..231881c2b355ef080aa1240079e0d9e1eb416ba5 100644 (file)
@@ -494,6 +494,7 @@ static void adf_obj_destroy(struct adf_obj *obj, struct idr *idr)
                struct adf_event_refcount *refcount =
                                container_of(node, struct adf_event_refcount,
                                                node);
+               rb_erase(&refcount->node, &obj->event_refcount);
                kfree(refcount);
                node = rb_first(&obj->event_refcount);
        }