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

Signed-off-by: Christophe JAILLET <[email protected]>
---
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 linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to