All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Disseldorp <ddiss@suse.de>
To: kernel-janitors@vger.kernel.org
Subject: Re: [patch]  target/iscsi: double free in lio_target_tiqn_addtpg()
Date: Tue, 13 Dec 2016 13:17:59 +0000	[thread overview]
Message-ID: <20161213141759.04213887@suse.de> (raw)
In-Reply-To: <20161213122703.GB7519@elgon.mountain>

On Tue, 13 Dec 2016 15:27:04 +0300, Dan Carpenter wrote:

> This iscsit_tpg_add_portal_group() function is only called from
> lio_target_tiqn_addtpg().  Both functions free the "tpg" pointer on
> error so it's a double free bug.  The memory is allocated in the caller
> so it should be freed in the caller and not here.
> 
> Fixes: e48354ce078c ("iscsi-target: Add iSCSI fabric support for target v4.1")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/target/iscsi/iscsi_target_tpg.c b/drivers/target/iscsi/iscsi_target_tpg.c
> index 0814e5894a96..205a509b0dfb 100644
> --- a/drivers/target/iscsi/iscsi_target_tpg.c
> +++ b/drivers/target/iscsi/iscsi_target_tpg.c
> @@ -260,7 +260,6 @@ int iscsit_tpg_add_portal_group(struct iscsi_tiqn *tiqn, struct iscsi_portal_gro
>  		iscsi_release_param_list(tpg->param_list);
>  		tpg->param_list = NULL;
>  	}
> -	kfree(tpg);
>  	return -ENOMEM;
>  }

Looks good, and works for me if I manually trigger the error path.
Reviewed-by: David Disseldorp <ddiss@suse.de>

  reply	other threads:[~2016-12-13 13:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-13 12:27 [patch] target/iscsi: double free in lio_target_tiqn_addtpg() Dan Carpenter
2016-12-13 13:17 ` David Disseldorp [this message]
2016-12-15 15:43 ` Bart Van Assche
2016-12-15 20:31 ` Dan Carpenter
2016-12-16 10:14 ` Bart Van Assche

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=20161213141759.04213887@suse.de \
    --to=ddiss@suse.de \
    --cc=kernel-janitors@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 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.