From: Baoquan He <bhe@redhat.com>
To: YoungHyun Yoo <yooyoo.yoo@samsung.com>
Cc: horms@verge.net.au, kexec@lists.infradead.org
Subject: Re: [PATCH] kexec: socket not released when error situation occur.
Date: Fri, 26 Aug 2016 10:17:47 +0800 [thread overview]
Message-ID: <20160826021747.GB327@x1.redhat.com> (raw)
In-Reply-To: <20160825021524.41728-1-yooyoo.yoo@samsung.com>
On 08/25/16 at 11:15am, YoungHyun Yoo wrote:
> Fix resourceleek in ifdown function when error occur.
resource leak?
>
> Signed-off-by: YoungHyun Yoo <yooyoo.yoo@samsung.com>
> ---
> kexec/ifdown.c | 26 +++++++++++++++-----------
> 1 file changed, 15 insertions(+), 11 deletions(-)
>
> diff --git a/kexec/ifdown.c b/kexec/ifdown.c
> index 46b7bef..9679ad7 100644
> --- a/kexec/ifdown.c
> +++ b/kexec/ifdown.c
> @@ -1,6 +1,6 @@
> /*
> - * ifdown.c Find all network interfaces on the system and
> - * shut them down.
> + * ifdown.c Find all network interfaces on the system and
> + * shut them down.
> *
> */
> char *v_ifdown = "@(#)ifdown.c 1.11 02-Jun-1998 miquels@cistron.nl";
> @@ -20,10 +20,10 @@ char *v_ifdown = "@(#)ifdown.c 1.11 02-Jun-1998 miquels@cistron.nl";
> #include <netinet/in.h>
>
> /*
> - * First, we find all shaper devices and down them. Then we
> - * down all real interfaces. This is because the comment in the
> - * shaper driver says "if you down the shaper device before the
> - * attached inerface your computer will follow".
> + * First, we find all shaper devices and down them. Then we
> + * down all real interfaces. This is because the comment in the
> + * shaper driver says "if you down the shaper device before the
> + * attached inerface your computer will follow".
> */
> int ifdown(void)
> {
> @@ -34,13 +34,13 @@ int ifdown(void)
> if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
> fprintf(stderr, "ifdown: ");
> perror("socket");
> - return -1;
> + goto error;
> }
>
> if ((ifa = if_nameindex()) == NULL) {
> fprintf(stderr, "ifdown: ");
> perror("if_nameindex");
> - return -1;
> + goto error;
> }
>
> for (shaper = 1; shaper >= 0; shaper--) {
> @@ -57,18 +57,22 @@ int ifdown(void)
> if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
> fprintf(stderr, "ifdown: shutdown ");
> perror(ifp->if_name);
> - return -1;
> + goto error;
> }
> ifr.ifr_flags &= ~(IFF_UP);
> if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) {
> fprintf(stderr, "ifdown: shutdown ");
> perror(ifp->if_name);
> - return -1;
> + goto error;
> }
>
> }
> }
> - close(fd);
>
> + close(fd);
> return 0;
> +
> +error:
> + close(fd);
> + return -1;
> }
> --
> 2.9.0.GIT
>
>
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2016-08-26 2:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-25 2:15 [PATCH] kexec: socket not released when error situation occur YoungHyun Yoo
2016-08-26 2:17 ` Baoquan He [this message]
2016-09-29 7:57 ` Simon Horman
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=20160826021747.GB327@x1.redhat.com \
--to=bhe@redhat.com \
--cc=horms@verge.net.au \
--cc=kexec@lists.infradead.org \
--cc=yooyoo.yoo@samsung.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.