Skip to contentSkip to conversation

Change the logic in obj_sock_adjust_users()

PATCH In review Dan Smith 2 participants 2 messages Sep 9, 2010 – Sep 16, 2010 1 message not in the archive

lore
Share & tools
lore

Dan Smith

author
#0 lore raw

PATCH 1/1 Change the logic in obj_sock_adjust_users()

The explicit decrement of obj->users isn't correct for all cases of SOCK_DEAD, so this patch changes it to the result of ref_users() to avoid the false positive in the leak check. I have confirmed with sockets in both SOCK_DEAD situations that we don't leak them with this change.

---
 kernel/checkpoint/objhash.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
kernel/checkpoint/objhash.c +2 -2
index a7b8b7d..62c34ff 100644
@@ -546,7 +546,7 @@ static void ckpt_obj_users_inc(struct ckpt_ctx *ctx, void *ptr, int increment)
  * obj_sock_adjust_users - remove implicit reference on DEAD sockets
  * @obj: CKPT_OBJ_SOCK object to adjust
  *
- * Sockets that have been disconnected from their struct file have
+ * Sockets that have been disconnected from their struct file may have
  * a reference count one less than normal sockets.  The objhash's
  * assumption of such a reference is therefore incorrect, so we correct
  * it here.
@@ -556,7 +556,7 @@ static inline void obj_sock_adjust_users(struct ckpt_obj *obj)
 	struct sock *sk = (struct sock *)obj->ptr;
 
 	if (sock_flag(sk, SOCK_DEAD)) {
-		obj->users--;
+		obj->users = obj->ops->ref_users(obj->ptr);
 		ckpt_debug("Adjusting SOCK %i count to %i\n",
 			   obj->objref, obj->users);
 	}
Signature · 1 line
1.7.2.2

A message that is not in the archive (sent off-list or not yet received): 1284071121-17701-1-git-send-email-danms-r/[email protected]

#2 lore raw

Simple enough - queued for v22-dev.

Oren

Quoted 33 lines · Dan Smith

The explicit decrement of obj->users isn't correct for all cases of SOCK_DEAD, so this patch changes it to the result of ref_users() to avoid the false positive in the leak check. I have confirmed with sockets in both SOCK_DEAD situations that we don't leak them with this change.

---
 kernel/checkpoint/objhash.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
kernel/checkpoint/objhash.c +2 -2
index a7b8b7d..62c34ff 100644
@@ -546,7 +546,7 @@ static void ckpt_obj_users_inc(struct ckpt_ctx *ctx, void *ptr, int increment)
  * obj_sock_adjust_users - remove implicit reference on DEAD sockets
  * @obj: CKPT_OBJ_SOCK object to adjust
  *
- * Sockets that have been disconnected from their struct file have
+ * Sockets that have been disconnected from their struct file may have
  * a reference count one less than normal sockets.  The objhash's
  * assumption of such a reference is therefore incorrect, so we correct
  * it here.
@@ -556,7 +556,7 @@ static inline void obj_sock_adjust_users(struct ckpt_obj *obj)
 	struct sock *sk = (struct sock *)obj->ptr;
 
 	if (sock_flag(sk, SOCK_DEAD)) {
-		obj->users--;
+		obj->users = obj->ops->ref_users(obj->ptr);
 		ckpt_debug("Adjusting SOCK %i count to %i\n",
 			   obj->objref, obj->users);
 	}