Re: [PATCH 5.10 027/118] nfc: nfcmrvl: Fix potential memory leak in nfcmrvl_i2c_nci_send()

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

 



Hi!

> From: Shang XiaoJing <shangxiaojing@xxxxxxxxxx>
> 
> [ Upstream commit 93d904a734a74c54d945a9884b4962977f1176cd ]
> 
> nfcmrvl_i2c_nci_send() will be called by nfcmrvl_nci_send(), and skb
> should be freed in nfcmrvl_i2c_nci_send(). However, nfcmrvl_nci_send()
> will only free skb when i2c_master_send() return >=0, which means skb
> will memleak when i2c_master_send() failed. Free skb no matter whether
> i2c_master_send() succeeds.

We still need to free the skb in the other error exits, right?

Best regards,
								Pavel
								
> +++ b/drivers/nfc/nfcmrvl/i2c.c
> @@ -151,10 +151,15 @@ static int nfcmrvl_i2c_nci_send(struct nfcmrvl_private *priv,
>  			ret = -EREMOTEIO;
>  		} else
>  			ret = 0;
> +	}
> +
> +	if (ret) {
>  		kfree_skb(skb);
> +		return ret;
>  	}
>  
> -	return ret;
> +	consume_skb(skb);
> +	return 0;
>  }
>  
>  static void nfcmrvl_i2c_nci_update_config(struct nfcmrvl_private *priv,

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux