Skip to contentSkip to conversation

svc: bzero the xprt memory in svc_xprt_init

RFC PATCH In review Tom Tucker 2 participants 2 messages Oct 12, 2007 – Oct 15, 2007

Subsystems (3)
lore
Share & tools
lore

Tom Tucker

author
#0 lore raw

RFC PATCH 1/1 svc: bzero the xprt memory in svc_xprt_init

The transport class driver is responsible for allocating the memory that contains svc_xprt. We don't know whether the driver used kzalloc or kmalloc. Initialize the svc_xprt structure to zeroes just in case.

Also changed the name of the svc_xprt ptr variable to xprt to be consistent with the naming used everywhere else for the transport ptr.

---

 net/sunrpc/svc_xprt.c |   21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 deletions(-)
net/sunrpc/svc_xprt.c +11 -10
index 56fcc7c..c823e66 100644
@@ -144,18 +144,19 @@ EXPORT_SYMBOL_GPL(svc_xprt_put);
  * Called by transport drivers to initialize the transport independent
  * portion of the transport instance.
  */
-void svc_xprt_init(struct svc_xprt_class *xcl, struct svc_xprt *xpt,
+void svc_xprt_init(struct svc_xprt_class *xcl, struct svc_xprt *xprt,
 		   struct svc_serv *serv)
 {
-	xpt->xpt_class = xcl;
-	xpt->xpt_ops = xcl->xcl_ops;
-	kref_init(&xpt->xpt_ref);
-	xpt->xpt_server = serv;
-	INIT_LIST_HEAD(&xpt->xpt_list);
-	INIT_LIST_HEAD(&xpt->xpt_ready);
-	INIT_LIST_HEAD(&xpt->xpt_deferred);
-	mutex_init(&xpt->xpt_mutex);
-	spin_lock_init(&xpt->xpt_lock);
+	memset(xprt, 0, sizeof(*xprt));
+	xprt->xpt_class = xcl;
+	xprt->xpt_ops = xcl->xcl_ops;
+	kref_init(&xprt->xpt_ref);
+	xprt->xpt_server = serv;
+	INIT_LIST_HEAD(&xprt->xpt_list);
+	INIT_LIST_HEAD(&xprt->xpt_ready);
+	INIT_LIST_HEAD(&xprt->xpt_deferred);
+	mutex_init(&xprt->xpt_mutex);
+	spin_lock_init(&xprt->xpt_lock);
 }
 EXPORT_SYMBOL_GPL(svc_xprt_init);
 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

#1 lore raw
Quoted 5 lines · Tom Tucker

The transport class driver is responsible for allocating the memory that contains svc_xprt. We don't know whether the driver used kzalloc or kmalloc. Initialize the svc_xprt structure to zeroes just in case.

ok.

Quoted 3 lines

Also changed the name of the svc_xprt ptr variable to xprt to be consistent with the naming used everywhere else for the transport ptr.

Cool, there's a lot to be said for consistency.

Greg.

Signature · 12 lines
Greg Banks, R&D Software Engineer, SGI Australian Software Group.
Apparently, I'm Bedevere.  Which MPHG character are you?
I don't speak for SGI.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
NFS maillist  -  [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs