X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=net%2Firda%2Firias_object.c;h=98c9e1517a2f162159a9ac5ac3d5265b22d1b124;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=058bf54dcb7eaa09a9ab18709eaa08caba9e52a0;hpb=87fc8d1bb10cd459024a742c6a10961fefcef18f;p=linux-2.6.git diff --git a/net/irda/irias_object.c b/net/irda/irias_object.c index 058bf54dc..98c9e1517 100644 --- a/net/irda/irias_object.c +++ b/net/irda/irias_object.c @@ -116,7 +116,7 @@ EXPORT_SYMBOL(irias_new_object); * Delete given attribute and deallocate all its memory * */ -void __irias_delete_attrib(struct ias_attrib *attrib) +static void __irias_delete_attrib(struct ias_attrib *attrib) { ASSERT(attrib != NULL, return;); ASSERT(attrib->magic == IAS_ATTRIB_MAGIC, return;); @@ -159,11 +159,14 @@ int irias_delete_object(struct ias_object *obj) ASSERT(obj != NULL, return -1;); ASSERT(obj->magic == IAS_OBJECT_MAGIC, return -1;); + /* Remove from list */ node = hashbin_remove_this(irias_objects, (irda_queue_t *) obj); if (!node) - return 0; /* Already removed */ + IRDA_DEBUG( 0, "%s(), object already removed!\n", + __FUNCTION__); - __irias_delete_object(node); + /* Destroy */ + __irias_delete_object(obj); return 0; } @@ -176,7 +179,8 @@ EXPORT_SYMBOL(irias_delete_object); * the object, remove the object as well. * */ -int irias_delete_attrib(struct ias_object *obj, struct ias_attrib *attrib) +int irias_delete_attrib(struct ias_object *obj, struct ias_attrib *attrib, + int cleanobject) { struct ias_attrib *node; @@ -192,9 +196,13 @@ int irias_delete_attrib(struct ias_object *obj, struct ias_attrib *attrib) /* Deallocate attribute */ __irias_delete_attrib(node); - /* Check if object has still some attributes */ + /* Check if object has still some attributes, destroy it if none. + * At first glance, this look dangerous, as the kernel reference + * various IAS objects. However, we only use this function on + * user attributes, not kernel attributes, so there is no risk + * of deleting a kernel object this way. Jean II */ node = (struct ias_attrib *) hashbin_get_first(obj->attribs); - if (!node) + if (cleanobject && !node) irias_delete_object(obj); return 0; @@ -259,8 +267,8 @@ EXPORT_SYMBOL(irias_find_attrib); * Add attribute to object * */ -void irias_add_attrib( struct ias_object *obj, struct ias_attrib *attrib, - int owner) +static void irias_add_attrib(struct ias_object *obj, struct ias_attrib *attrib, + int owner) { ASSERT(obj != NULL, return;); ASSERT(obj->magic == IAS_OBJECT_MAGIC, return;);