RE: [PATCH] libfc: fix mem leak in fc_seq_assign()

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

 



> 
> There seems exchs should get released in cases that FC_RJT_NONE is
> returned, or they will no longer get freed.
> 
> It also looks a typo like the following,
> 
> -		    fc_seq_lookup_recip(lport, ema->mp, fp) != FC_RJT_NONE)
> +		    fc_seq_lookup_recip(lport, ema->mp, fp) == FC_RJT_NONE)
> 
> but I am not sure.
> 
> Signed-off-by: Hillf Danton <dhillf@xxxxxxxxx>
> ---
> 
> --- a/drivers/scsi/libfc/fc_exch.c	2010-09-13 07:07:38.000000000 +0800
> +++ b/drivers/scsi/libfc/fc_exch.c	2010-10-19 21:48:22.000000000 +0800
> @@ -3,6 +3,9 @@
>   * Copyright(c) 2008 Red Hat, Inc.  All rights reserved.
>   * Copyright(c) 2008 Mike Christie
>   *
> + * Copyright(c) Oct 19, 2010	Hillf Danton
> + *				minor fix of memory leakage
> + *
>   * This program is free software; you can redistribute it and/or modify
> it
>   * under the terms and conditions of the GNU General Public License,
>   * version 2, as published by the Free Software Foundation.
> @@ -1246,9 +1249,16 @@ static struct fc_seq *fc_seq_assign(stru
>  	fr_seq(fp) = NULL;
> 
>  	list_for_each_entry(ema, &lport->ema_list, ema_list)
> -		if ((!ema->match || ema->match(fp)) &&
> -		    fc_seq_lookup_recip(lport, ema->mp, fp) != FC_RJT_NONE)
> -			break;
> +		if (! ema->match || ema->match(fp))
> +			if (fc_seq_lookup_recip(lport, ema->mp, fp) !=
> +				FC_RJT_NONE)
> +				break;
This looks more to be a '==' here as you pointed out since you either 
get a rejection code or have found/allocated exchange via the lookup_recip()
here. When not RJT_NONE, try next em in the list, however, does not look
like anywhere the RJT is sent back when not RJT_NONE. Probably the caller
would check if the return being NULL then send its own rejection code.

> +			else {
> +				struct fc_seq *seq = fr_seq(fp);
> +				struct fc_exch *exch = fc_seq_exch(seq);
> +				fc_exch_release(exch);
> +			}
> +
I believe you want to hold the exch here if you find one.

>  	return fr_seq(fp);
>  }


ÿô.nlj·Ÿ®‰­†+%ŠË±é¥Šwÿº{.nlj·¥Š{±þÇ‹ø¡Ü}©ž²ÆzÚj:+v‰¨þø®w¥þŠàÞ¨è&¢)ß«a¶Úÿûz¹ÞúŽŠÝjÿŠwèf



[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