]> git.hungrycats.org Git - linux/commitdiff
[IRDA]: IAS safety comments
authorJean Tourrilhes <jt@bougret.hpl.hp.com>
Thu, 21 Oct 2004 15:08:56 +0000 (08:08 -0700)
committerDavid S. Miller <davem@nuts.davemloft.net>
Thu, 21 Oct 2004 15:08:56 +0000 (08:08 -0700)
o [FEATURE] Make optional the del of IAS object when del IAS attrib
o [FEATURE] Clarify when/why it's safe to to the above

Signed-off-by: Jean Tourrilhes <jt@hpl.hp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/irda/irias_object.h
net/irda/af_irda.c
net/irda/irias_object.c

index 6ffaed3291c0cefdf2c407c35b6e3253b7cca917..c41196b879556fa2ccd5d73917b75cb599f27d47 100644 (file)
@@ -81,7 +81,8 @@ struct ias_attrib {
 struct ias_object *irias_new_object(char *name, int id);
 void irias_insert_object(struct ias_object *obj);
 int  irias_delete_object(struct ias_object *obj);
-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);
 void __irias_delete_object(struct ias_object *obj);
 
 void irias_add_integer_attrib(struct ias_object *obj, char *name, int value,
index f415a4e0645e9837e885891ac5ba03d69db5ae75..bc6aa5db3bb5906eb7e68b664412b8c4f29dc2b4 100644 (file)
@@ -2005,7 +2005,7 @@ static int irda_setsockopt(struct socket *sock, int level, int optname,
                }
 
                /* Remove the attribute (and maybe the object) */
-               irias_delete_attrib(ias_obj, ias_attr);
+               irias_delete_attrib(ias_obj, ias_attr, 1);
                kfree(ias_opt);
                break;
        case IRLMP_MAX_SDU_SIZE:
index 058bf54dcb7eaa09a9ab18709eaa08caba9e52a0..bc8d74df15639917d3a0fc23a0453d31278216d3 100644 (file)
@@ -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;