Skip to contentSkip to conversation

'dom' error handled, by raising ENOMEM if failure occurs. 'xs_fd' leak handled in success path.

PATCH In review Lasya 3 participants 5 messages Oct 27, 2015

lore
Share & tools
lore

Lasya

author
#0 lore raw

PATCH 1/1 'dom' error handled, by raising ENOMEM if failure occurs. 'xs_fd' leak handled in success path.

---
 tools/xenstore/init-xenstore-domain.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tools/xenstore/init-xenstore-domain.c +6 -1
index 0d12169..b413b09 100644
@@ -42,6 +42,10 @@ static int build(xc_interface *xch, int argc, char** argv)
 	snprintf(cmdline, 512, "--event %d --internal-db", rv);
 
 	dom = xc_dom_allocate(xch, cmdline, NULL);
+	if(dom==NULL) {
+		rv=ENOMEM;
+		goto err;
+	}
 	rv = xc_dom_kernel_file(dom, argv[1]);
 	if (rv) goto err;
 
@@ -70,7 +74,8 @@ static int build(xc_interface *xch, int argc, char** argv)
 	if (rv) goto err;
 	rv = xc_domain_unpause(xch, domid);
 	if (rv) goto err;
-
+	
+	close(xs_fd);
 	return 0;
 
 err:
Signature · 1 line
1.9.1
#1 lore raw

On Wed, 2015-10-28 at 03:49 +0530, Lasya wrote:

The description of the patch, that you previously put in a separate email, should live here.

Also, this is the second version of a patch. That should be evident from the subject line (something like "[PATCH v2]").

And still about the subject line, it's a bit long. It must contain a very quick hint at what the patch is about, then all the details go in the patch description (also called changelog), i.e., right in here. :-)

Quoted 11 lines
---
 tools/xenstore/init-xenstore-domain.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tools/xenstore/init-xenstore-domain.c +0 -0
index 0d12169..b413b09 100644

tools/xenstore/init-xenstore-domain.c static int build(xc_interface *xch, int argc, · line 50

Quoted 9 lines
tools/xenstore/init-xenstore-domain.c +4 -0
@@ -42,6 +42,10 @@ static int build(xc_interface *xch, int argc,
 char** argv)
 	snprintf(cmdline, 512, "--event %d --internal-db", rv);
 
 	dom = xc_dom_allocate(xch, cmdline, NULL);
+	if(dom==NULL) {
+		rv=ENOMEM;
+		goto err;
+	}
 

A lot of spaces are missing...

tools/xenstore/init-xenstore-domain.c static int build(xc_interface *xch, int argc, char** argv) · line 49

Quoted 1 line
tools/xenstore/init-xenstore-domain.c +0 -0
 	rv = xc_dom_kernel_file(dom, argv[1]);
          ^ ^
          | |
          -----------------------------------------------
                                                        |

Just, for instance, compare what you added with this: ---

Quoted 1 line

if (rv) goto err;

          ^
          |
          --------
                 |

And with this: ---

tools/xenstore/init-xenstore-domain.c static int build(xc_interface *xch, int argc, · line 79

Quoted 8 lines
tools/xenstore/init-xenstore-domain.c +1 -1
@@ -70,7 +74,8 @@ static int build(xc_interface *xch, int argc,
 char** argv)
 	if (rv) goto err;
 	rv = xc_domain_unpause(xch, domid);
 	if (rv) goto err;
-
+	
 

What happened here?

tools/xenstore/init-xenstore-domain.c static int build(xc_interface *xch, int argc, char** argv) · line 79

Quoted 3 lines
tools/xenstore/init-xenstore-domain.c +1 -0
+	close(xs_fd);
 	return 0;

Also, Wei suggested to send two patches, one for fixing the error handling for xc_dom_allocate(), and another one for stopping leaking the fd on the success path.

Regards,
Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#2 lore raw
Quoted 5 lines · Dario Faggioli

On Wed, 2015-10-28 at 03:49 +0530, Lasya wrote:

The description of the patch, that you previously put in a separate email, should live here.

Oh, I had thought no cover letter was needed. Hence, I didn't put in a description, I shall add it in v3. :)

Quoted 8 lines

Also, this is the second version of a patch. That should be evident from the subject line (something like "[PATCH v2]").

And still about the subject line, it's a bit long. It must contain a very quick hint at what the patch is about, then all the details go in the patch description (also called changelog), i.e., right in here. :-)

The subject line was picked up from the commit message, I shall put a concise one this time.

Quoted 37 lines
Quoted 12 lines
---
 tools/xenstore/init-xenstore-domain.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tools/xenstore/init-xenstore-domain.c +0 -0
index 0d12169..b413b09 100644

tools/xenstore/init-xenstore-domain.c static int build(xc_interface *xch, int argc, · line 50

Quoted 9 lines
tools/xenstore/init-xenstore-domain.c +4 -0
@@ -42,6 +42,10 @@ static int build(xc_interface *xch, int argc,
 char** argv)
      snprintf(cmdline, 512, "--event %d --internal-db", rv);
 
      dom = xc_dom_allocate(xch, cmdline, NULL);
+     if(dom==NULL) {
+             rv=ENOMEM;
+             goto err;
+     }
 

A lot of spaces are missing...

tools/xenstore/init-xenstore-domain.c static int build(xc_interface *xch, int argc, char** argv) · line 49

Quoted 1 line
tools/xenstore/init-xenstore-domain.c +0 -0
      rv = xc_dom_kernel_file(dom, argv[1]);
          ^ ^
          | |
          -----------------------------------------------
                                                        |

Just, for instance, compare what you added with this: ---

Quoted 1 line
      if (rv) goto err;
          ^
          |
          --------
                 |

And with this: ---

Quoted 9 lines

tools/xenstore/init-xenstore-domain.c static int build(xc_interface *xch, int argc, · line 79

Quoted 8 lines
tools/xenstore/init-xenstore-domain.c +1 -1
@@ -70,7 +74,8 @@ static int build(xc_interface *xch, int argc,
 char** argv)
      if (rv) goto err;
      rv = xc_domain_unpause(xch, domid);
      if (rv) goto err;
-
+
 

Dario, I wasn't look at the individual spaces, just the line breaks. Will be careful this time.

Quoted 5 lines

What happened here?

tools/xenstore/init-xenstore-domain.c static int build(xc_interface *xch, int argc, char** argv) · line 79

Quoted 3 lines
tools/xenstore/init-xenstore-domain.c +1 -0
+     close(xs_fd);
      return 0;
Quoted 7 lines

Also, Wei suggested to send two patches, one for fixing the error handling for xc_dom_allocate(), and another one for stopping leaking the fd on the success path.

Regards,
Dario

Okay. I shall send them in as two patches.

Thank you for being so patient with this.
Regards
Lasya V

Quoted 7 lines

--
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw
Quoted 10 lines · Lasya Venneti
Quoted 5 lines · Dario Faggioli

On Wed, 2015-10-28 at 03:49 +0530, Lasya wrote:

The description of the patch, that you previously put in a separate email, should live here.

Oh, I had thought no cover letter was needed. Hence, I didn't put in a description, I shall add it in v3. :)

Please also read carefully the section titled "Making good patches" in the Submitting Xen Project Patches wiki page [1].

[1] http://wiki.xenproject.org/wiki/Submitting_Xen_Project_Patches

-George

Quoted 87 lines
Quoted 9 lines

Also, this is the second version of a patch. That should be evident from the subject line (something like "[PATCH v2]").

And still about the subject line, it's a bit long. It must contain a very quick hint at what the patch is about, then all the details go in the patch description (also called changelog), i.e., right in here. :-)

The subject line was picked up from the commit message, I shall put a concise one this time.

Quoted 37 lines
Quoted 12 lines
---
 tools/xenstore/init-xenstore-domain.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tools/xenstore/init-xenstore-domain.c +0 -0
index 0d12169..b413b09 100644

tools/xenstore/init-xenstore-domain.c static int build(xc_interface *xch, int argc, · line 50

Quoted 9 lines
tools/xenstore/init-xenstore-domain.c +4 -0
@@ -42,6 +42,10 @@ static int build(xc_interface *xch, int argc,
 char** argv)
      snprintf(cmdline, 512, "--event %d --internal-db", rv);
 
      dom = xc_dom_allocate(xch, cmdline, NULL);
+     if(dom==NULL) {
+             rv=ENOMEM;
+             goto err;
+     }
 

A lot of spaces are missing...

tools/xenstore/init-xenstore-domain.c static int build(xc_interface *xch, int argc, char** argv) · line 49

Quoted 1 line
tools/xenstore/init-xenstore-domain.c +0 -0
      rv = xc_dom_kernel_file(dom, argv[1]);
          ^ ^
          | |
          -----------------------------------------------
                                                        |

Just, for instance, compare what you added with this: ---

Quoted 1 line
      if (rv) goto err;
          ^
          |
          --------
                 |

And with this: ---

Quoted 9 lines

tools/xenstore/init-xenstore-domain.c static int build(xc_interface *xch, int argc, · line 79

Quoted 8 lines
tools/xenstore/init-xenstore-domain.c +1 -1
@@ -70,7 +74,8 @@ static int build(xc_interface *xch, int argc,
 char** argv)
      if (rv) goto err;
      rv = xc_domain_unpause(xch, domid);
      if (rv) goto err;
-
+
 

Dario, I wasn't look at the individual spaces, just the line breaks. Will be careful this time.

Quoted 5 lines

What happened here?

tools/xenstore/init-xenstore-domain.c static int build(xc_interface *xch, int argc, char** argv) · line 79

Quoted 3 lines
tools/xenstore/init-xenstore-domain.c +1 -0
+     close(xs_fd);
      return 0;
Quoted 7 lines

Also, Wei suggested to send two patches, one for fixing the error handling for xc_dom_allocate(), and another one for stopping leaking the fd on the success path.

Regards,
Dario

Okay. I shall send them in as two patches.

Thank you for being so patient with this.
Regards
Lasya V

Quoted 7 lines

--
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

#4 lore raw
Quoted 9 lines · George Dunlap
Quoted 8 lines · Lasya Venneti
Quoted 5 lines · Dario Faggioli

On Wed, 2015-10-28 at 03:49 +0530, Lasya wrote:

The description of the patch, that you previously put in a separate email, should live here.

Quoted 8 lines
Quoted 2 lines

Oh, I had thought no cover letter was needed. Hence, I didn't put in a description, I shall add it in v3. :)

Please also read carefully the section titled "Making good patches" in the Submitting Xen Project Patches wiki page [1].

[1] http://wiki.xenproject.org/wiki/Submitting_Xen_Project_Patches

I will definitely go through this thoroughly. Thank you for the resource.

Regards
Lasya V

Quoted 92 lines

-George

Quoted 87 lines
Quoted 9 lines

Also, this is the second version of a patch. That should be evident from the subject line (something like "[PATCH v2]").

And still about the subject line, it's a bit long. It must contain a very quick hint at what the patch is about, then all the details go in the patch description (also called changelog), i.e., right in here. :-)

The subject line was picked up from the commit message, I shall put a concise one this time.

Quoted 37 lines
Quoted 12 lines
---
 tools/xenstore/init-xenstore-domain.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tools/xenstore/init-xenstore-domain.c +0 -0
index 0d12169..b413b09 100644

tools/xenstore/init-xenstore-domain.c static int build(xc_interface *xch, int argc, · line 50

Quoted 9 lines
tools/xenstore/init-xenstore-domain.c +4 -0
@@ -42,6 +42,10 @@ static int build(xc_interface *xch, int argc,
 char** argv)
      snprintf(cmdline, 512, "--event %d --internal-db", rv);
 
      dom = xc_dom_allocate(xch, cmdline, NULL);
+     if(dom==NULL) {
+             rv=ENOMEM;
+             goto err;
+     }
 

A lot of spaces are missing...

tools/xenstore/init-xenstore-domain.c static int build(xc_interface *xch, int argc, char** argv) · line 49

Quoted 1 line
tools/xenstore/init-xenstore-domain.c +0 -0
      rv = xc_dom_kernel_file(dom, argv[1]);
          ^ ^
          | |
          -----------------------------------------------
                                                        |

Just, for instance, compare what you added with this: ---

Quoted 1 line
      if (rv) goto err;
          ^
          |
          --------
                 |

And with this: ---

Quoted 9 lines

tools/xenstore/init-xenstore-domain.c static int build(xc_interface *xch, int argc, · line 79

Quoted 8 lines
tools/xenstore/init-xenstore-domain.c +1 -1
@@ -70,7 +74,8 @@ static int build(xc_interface *xch, int argc,
 char** argv)
      if (rv) goto err;
      rv = xc_domain_unpause(xch, domid);
      if (rv) goto err;
-
+
 

Dario, I wasn't look at the individual spaces, just the line breaks. Will be careful this time.

Quoted 5 lines

What happened here?

tools/xenstore/init-xenstore-domain.c static int build(xc_interface *xch, int argc, char** argv) · line 79

Quoted 3 lines
tools/xenstore/init-xenstore-domain.c +1 -0
+     close(xs_fd);
      return 0;
Quoted 7 lines

Also, Wei suggested to send two patches, one for fixing the error handling for xc_dom_allocate(), and another one for stopping leaking the fd on the success path.

Regards,
Dario

Okay. I shall send them in as two patches.

Thank you for being so patient with this.
Regards
Lasya V

Quoted 7 lines

--
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel