target-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Christie <mchristi@redhat.com>
To: Chengguang Xu <cgxu519@gmx.com>, nab@linux-iscsi.org
Cc: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [RESEND PATCH] target: fix potential memory leak in option parsing
Date: Wed, 13 Jun 2018 16:10:29 +0000	[thread overview]
Message-ID: <5B2141F5.5080102@redhat.com> (raw)
In-Reply-To: <1528867646-138322-1-git-send-email-cgxu519@gmx.com>

On 06/13/2018 12:27 AM, Chengguang Xu wrote:
> When specifying same string type option several times,
> current option parsing will cause memory leak. Hence,
> call kfree for previous one in this case.
> 
> Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
> ---
>  drivers/target/target_core_configfs.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
> index 5ccef7d..5512432 100644
> --- a/drivers/target/target_core_configfs.c
> +++ b/drivers/target/target_core_configfs.c
> @@ -1661,6 +1661,7 @@ static ssize_t target_pr_res_aptpl_metadata_store(struct config_item *item,
>  		token = match_token(ptr, tokens, args);
>  		switch (token) {
>  		case Opt_initiator_fabric:
> +			kfree(i_fabric);

You can probably just change this one and t_fabric so we do not even do
a match_strdup since they are not used. Just let them hit the default in
the switch so if apps are still passing them in then we maintain the
same behavior from their perspective.

      reply	other threads:[~2018-06-13 16:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-13  5:27 [RESEND PATCH] target: fix potential memory leak in option parsing Chengguang Xu
2018-06-13 16:10 ` Mike Christie [this message]

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=5B2141F5.5080102@redhat.com \
    --to=mchristi@redhat.com \
    --cc=cgxu519@gmx.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=nab@linux-iscsi.org \
    --cc=target-devel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).