mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jean Tourrilhes <jt@bougret.hpl.hp.com>
To: "David S. Miller" <davem@davemloft.net>,
	Linux kernel mailing list <linux-kernel@vger.kernel.org>
Subject: [PATCH 2.6 IrDA] IAS safety comments
Date: Tue, 19 Oct 2004 18:03:45 -0700	[thread overview]
Message-ID: <20041020010345.GE12932@bougret.hpl.hp.com> (raw)

ir269_ias_safety.diff :
~~~~~~~~~~~~~~~~~~~~~
	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>


diff -u -p linux/include/net/irda/irias_object.d0.h linux/include/net/irda/irias_object.h
--- linux/include/net/irda/irias_object.d0.h	Tue Sep 21 11:41:13 2004
+++ linux/include/net/irda/irias_object.h	Tue Sep 21 11:50:18 2004
@@ -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,
diff -u -p linux/net/irda/irias_object.d0.c linux/net/irda/irias_object.c
--- linux/net/irda/irias_object.d0.c	Tue Sep 21 11:31:31 2004
+++ linux/net/irda/irias_object.c	Tue Sep 21 11:50:11 2004
@@ -159,11 +159,14 @@ int irias_delete_object(struct ias_objec
 	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_objec
 	/* 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;
diff -u -p linux/net/irda/af_irda.d0.c linux/net/irda/af_irda.c
--- linux/net/irda/af_irda.d0.c	Tue Sep 21 12:16:29 2004
+++ linux/net/irda/af_irda.c	Tue Sep 21 11:47:06 2004
@@ -2005,7 +2005,7 @@ static int irda_setsockopt(struct socket
 		}
 
 		/* 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:

                 reply	other threads:[~2004-10-20  1:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20041020010345.GE12932@bougret.hpl.hp.com \
    --to=jt@bougret.hpl.hp.com \
    --cc=davem@davemloft.net \
    --cc=jt@hpl.hp.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®