Re: [PATCH -next] target: fix possible memory leak in core_tpg_register()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2013-03-15 at 17:19 +0800, Wei Yongjun wrote:
> From: Wei Yongjun <yongjun_wei@xxxxxxxxxxxxxxxxx>
> 
> 'se_tpg->tpg_lun_list' is malloced in core_tpg_register() and should be freed
> before leaving from the error handling cases, otherwise it will cause memory
> leak. 
> 'se_tpg' is malloced out of this function, and will be freed if we return error, so
> remove free for 'se_tpg'.
> 
> Signed-off-by: Wei Yongjun <yongjun_wei@xxxxxxxxxxxxxxxxx>
> ---

Applied to target-pending/master, and including in the next
v3.9-rc-fixes pull request.

Thanks Wei!

--nab

>  drivers/target/target_core_tpg.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
> index 9169d6a..aac9d27 100644
> --- a/drivers/target/target_core_tpg.c
> +++ b/drivers/target/target_core_tpg.c
> @@ -711,7 +711,8 @@ int core_tpg_register(
>  
>  	if (se_tpg->se_tpg_type == TRANSPORT_TPG_TYPE_NORMAL) {
>  		if (core_tpg_setup_virtual_lun0(se_tpg) < 0) {
> -			kfree(se_tpg);
> +			array_free(se_tpg->tpg_lun_list,
> +				   TRANSPORT_MAX_LUNS_PER_TPG);
>  			return -ENOMEM;
>  		}
>  	}
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe target-devel" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux