From: Bernard Pidoux <bernard.pidoux@upmc.fr>
To: Ralf Baechle <ralf@linux-mips.org>
Cc: Jarek Poplawski <jarkao2@gmail.com>,
David Miller <davem@davemloft.net>,
Bernard Pidoux F6BVP <f6bvp@free.fr>,
Linux Netdev List <netdev@vger.kernel.org>,
linux-hams <linux-hams@vger.kernel.org>
Subject: Re: [PATCH] ax25: Add missing dev_put in ax25_setsockopt
Date: Mon, 28 Sep 2009 19:46:06 +0200 [thread overview]
Message-ID: <4AC0F65E.9040401@upmc.fr> (raw)
In-Reply-To: <20090928125313.GA14250@linux-mips.org>
Hi take this one too. Hi.
Applied.
Thanks Ralf.
Bernard
Ralf Baechle a écrit :
> ax25_setsockopt SO_BINDTODEVICE is missing a dev_put call in case of
> success. Re-order code to fix this bug. While at it also reformat two
> lines of code to comply with the Linux coding style.
>
> Initial patch by Jarek Poplawski <jarkao2@gmail.com>.
>
> Reported-by: Bernard Pidoux F6BVP <f6bvp@free.fr>
> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
>
> ---
> Counter-proposal. Reordering all the code avoids the need for a 2nd dev_put
> and is more readable.
>
> Ralf
>
> net/ax25/af_ax25.c | 19 ++++++++++---------
> 1 files changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
> index fbcac76..4102de1 100644
> --- a/net/ax25/af_ax25.c
> +++ b/net/ax25/af_ax25.c
> @@ -641,15 +641,10 @@ static int ax25_setsockopt(struct socket *sock, int level, int optname,
>
> case SO_BINDTODEVICE:
> if (optlen > IFNAMSIZ)
> - optlen=IFNAMSIZ;
> - if (copy_from_user(devname, optval, optlen)) {
> - res = -EFAULT;
> - break;
> - }
> + optlen = IFNAMSIZ;
>
> - dev = dev_get_by_name(&init_net, devname);
> - if (dev == NULL) {
> - res = -ENODEV;
> + if (copy_from_user(devname, optval, optlen)) {
> + res = -EFAULT;
> break;
> }
>
> @@ -657,12 +652,18 @@ static int ax25_setsockopt(struct socket *sock, int level, int optname,
> (sock->state != SS_UNCONNECTED ||
> sk->sk_state == TCP_LISTEN)) {
> res = -EADDRNOTAVAIL;
> - dev_put(dev);
> + break;
> + }
> +
> + dev = dev_get_by_name(&init_net, devname);
> + if (!dev) {
> + res = -ENODEV;
> break;
> }
>
> ax25->ax25_dev = ax25_dev_ax25dev(dev);
> ax25_fillin_cb(ax25, ax25->ax25_dev);
> + dev_put(dev);
> break;
>
> default:
>
next prev parent reply other threads:[~2009-09-28 17:46 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-21 20:11 [AX25] kernel panic Jarek Poplawski
2009-09-23 21:17 ` Bernard Pidoux F6BVP
2009-09-24 8:07 ` Jarek Poplawski
2009-09-25 13:10 ` [PATCH] ax25: Fix ax25_cb refcounting in ax25_ctl_ioctl Jarek Poplawski
2009-09-25 13:40 ` Ralf Baechle DL5RB
2009-09-25 18:35 ` Jarek Poplawski
2009-09-25 19:10 ` David Miller
2009-09-25 19:50 ` Bernard Pidoux
2009-09-25 20:29 ` Jarek Poplawski
2009-09-27 7:23 ` Ralf Baechle DL5RB
2009-09-27 17:10 ` Jarek Poplawski
2009-09-27 19:02 ` Jarek Poplawski
2009-09-27 20:57 ` [PATCH] ax25: Fix possible oops in ax25_make_new Jarek Poplawski
2009-09-28 10:47 ` Bernard Pidoux F6BVP
2009-09-30 23:44 ` David Miller
2009-09-28 7:12 ` [PATCH] ax25: Add missing dev_put in ax25_setsockopt Jarek Poplawski
2009-09-28 10:48 ` Bernard Pidoux F6BVP
2009-09-28 12:53 ` Ralf Baechle
2009-09-28 17:46 ` Bernard Pidoux [this message]
2009-09-28 19:26 ` David Miller
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=4AC0F65E.9040401@upmc.fr \
--to=bernard.pidoux@upmc.fr \
--cc=davem@davemloft.net \
--cc=f6bvp@free.fr \
--cc=jarkao2@gmail.com \
--cc=linux-hams@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=ralf@linux-mips.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