[PATCH] ia64: sn2: Add missing kfree in error path

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

 



If 'ia64_sn_hwperf_op' fails, then 'ptdata' should be freed, otherwise,
there is a memory leak.

Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
---
This patch is *untested* because I have no way to trigger the error.
---
 arch/ia64/sn/kernel/sn2/sn_hwperf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/ia64/sn/kernel/sn2/sn_hwperf.c b/arch/ia64/sn/kernel/sn2/sn_hwperf.c
index b999257..9e1694f 100644
--- a/arch/ia64/sn/kernel/sn2/sn_hwperf.c
+++ b/arch/ia64/sn/kernel/sn2/sn_hwperf.c
@@ -499,8 +499,10 @@ static int sn_topology_show(struct seq_file *s, void *d)
 		e = ia64_sn_hwperf_op(sn_hwperf_master_nasid,
 				      SN_HWPERF_ENUM_PORTS, obj->id, sz,
 				      (u64) ptdata, 0, 0, NULL);
-		if (e != SN_HWPERF_OP_OK)
+		if (e != SN_HWPERF_OP_OK) {
+			kfree(ptdata);
 			return -EINVAL;
+		}
 		for (ordinal=0, p=objs; p != obj; p++) {
 			if (!SN_HWPERF_FOREIGN(p))
 				ordinal += p->ports;
-- 
2.1.4

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



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux