From: Anton Ivanov <anton.ivanov@cambridgegreys.com>
To: SF Markus Elfring <elfring@users.sourceforge.net>,
user-mode-linux-devel@lists.sourceforge.net,
Jeff Dike <jdike@addtoit.com>,
Richard Weinberger <richard@nod.at>
Cc: user-mode-linux-user@lists.sourceforge.net,
kernel-janitors@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/9] um/drivers/vector_user: Delete unnecessary code in user_init_raw_fds()
Date: Sun, 11 Mar 2018 18:08:22 +0000 [thread overview]
Message-ID: <33ff08e8-39cd-8558-152f-dac474fb0b5b@cambridgegreys.com> (raw)
In-Reply-To: <a8ec6fce-df95-10a9-6dd7-3604fd403d0d@users.sourceforge.net>
Thanks, well noted.
It still does not fix it completely though.
Re-reading the code it will leak a fd if the malloc for result fails.
That return result; there should be inside the conditional falling back
to cleanup if the alloc fails.
A.
On 03/11/18 15:16, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 11 Mar 2018 11:36:18 +0100
>
> * One condition check could never be reached with a non-null pointer
> at the end of this function. Thus remove the corresponding statement.
>
> * Delete an initialisation for the local variable "result"
> which became unnecessary with this refactoring.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> arch/um/drivers/vector_user.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/arch/um/drivers/vector_user.c b/arch/um/drivers/vector_user.c
> index 4291f1a5d342..d6a6207d4061 100644
> --- a/arch/um/drivers/vector_user.c
> +++ b/arch/um/drivers/vector_user.c
> @@ -211,7 +211,7 @@ static struct vector_fds *user_init_raw_fds(struct arglist *ifspec)
> struct sockaddr_ll sock;
> int err = -ENOMEM;
> char *iface;
> - struct vector_fds *result = NULL;
> + struct vector_fds *result;
> int optval = 1;
>
>
> @@ -276,8 +276,6 @@ static struct vector_fds *user_init_raw_fds(struct arglist *ifspec)
> os_close_file(rxfd);
> if (txfd >= 0)
> os_close_file(txfd);
> - if (result != NULL)
> - kfree(result);
> return NULL;
> }
>
--
Anton R. Ivanov
Cambridge Greys Limited, England and Wales company No 10273661
http://www.cambridgegreys.com/
next prev parent reply other threads:[~2018-03-11 18:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-11 15:15 [PATCH 0/9] UML vector network driver: Adjustments for three function implementations SF Markus Elfring
2018-03-11 15:16 ` [PATCH 1/9] um/drivers/vector_user: Delete unnecessary code in user_init_raw_fds() SF Markus Elfring
2018-03-11 18:08 ` Anton Ivanov [this message]
2018-03-11 15:17 ` [PATCH 2/9] um/drivers/vector_user: Less checks in user_init_raw_fds() after error detection SF Markus Elfring
2018-03-13 7:08 ` [2/9] " SF Markus Elfring
2018-03-11 15:18 ` [PATCH 3/9] um/drivers/vector_user: Adjust an error message in user_init_socket_fds() SF Markus Elfring
2018-03-11 15:19 ` [PATCH 4/9] um/drivers/vector_user: Delete an unnecessary check before kfree() " SF Markus Elfring
2018-03-11 15:20 ` [PATCH 5/9] um/drivers/vector_user: Delete two unnecessary checks before freeaddrinfo() " SF Markus Elfring
2018-03-11 15:21 ` [PATCH 6/9] um/drivers/vector_user: Less checks in user_init_socket_fds() after error detection SF Markus Elfring
2018-03-11 15:22 ` [PATCH 7/9] um/drivers/vector_user: Adjust an error message in user_init_tap_fds() SF Markus Elfring
2018-03-11 15:23 ` [PATCH 8/9] um/drivers/vector_user: Less checks in user_init_tap_fds() after error detection SF Markus Elfring
2018-03-11 15:24 ` [PATCH 9/9] um/drivers/vector_user: Delete an unnecessary variable initialisation in user_init_tap_fds() SF Markus Elfring
2018-03-29 19:51 ` [0/9] UML vector network driver: Adjustments for three function implementations SF Markus Elfring
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=33ff08e8-39cd-8558-152f-dac474fb0b5b@cambridgegreys.com \
--to=anton.ivanov@cambridgegreys.com \
--cc=elfring@users.sourceforge.net \
--cc=jdike@addtoit.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=richard@nod.at \
--cc=user-mode-linux-devel@lists.sourceforge.net \
--cc=user-mode-linux-user@lists.sourceforge.net \
/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
all inboxes | Powered by JetHome®