Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752034AbdITVDG (ORCPT ); Wed, 20 Sep 2017 17:03:06 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:46752 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751751AbdITVDD (ORCPT ); Wed, 20 Sep 2017 17:03:03 -0400 From: Tyrel Datwyler To: mpe@ellerman.id.au Cc: linuxppc-dev@lists.ozlabs.org, robh+dt@kernel.org, abdhalee@linux.vnet.ibm.com, paulus@samba.org, sachinp@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, Tyrel Datwyler , stable@vger.kernel.org, #@b01ledav001.gho.pok.ibm.com, v3.12+@b01ledav001.gho.pok.ibm.com Subject: [PATCH 2/2] powerpc/pseries: fix parent_dn reference leak in add_dt_node() Date: Wed, 20 Sep 2017 17:02:52 -0400 X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1505941372-9147-1-git-send-email-tyreld@linux.vnet.ibm.com> References: <1505473476.9665.13.camel@abdul.in.ibm.com> <1505941372-9147-1-git-send-email-tyreld@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17092021-0024-0000-0000-000002D553FD X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007769; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000230; SDB=6.00919915; UDB=6.00462199; IPR=6.00700141; BA=6.00005599; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017225; XFM=3.00000015; UTC=2017-09-20 21:03:00 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17092021-0025-0000-0000-0000457D3E46 Message-Id: <1505941372-9147-2-git-send-email-tyreld@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-09-20_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1709200281 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1124 Lines: 32 A reference to the parent device node is held by add_dt_node() for the node to be added. If the call to dlpar_configure_connector() fails add_dt_node() returns ENOENT and that reference is not freed. Add a call to of_node_put(parent_dn) prior to bailing out after a failed dlpar_configure_connector() call. Cc: stable@vger.kernel.org # v3.12+ Fixes: 8d5ff320766f ("powerpc/pseries: Make dlpar_configure_connector parent node aware") Signed-off-by: Tyrel Datwyler --- arch/powerpc/platforms/pseries/mobility.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/pseries/mobility.c b/arch/powerpc/platforms/pseries/mobility.c index 210ce63..f7042ad 100644 --- a/arch/powerpc/platforms/pseries/mobility.c +++ b/arch/powerpc/platforms/pseries/mobility.c @@ -226,8 +226,10 @@ static int add_dt_node(__be32 parent_phandle, __be32 drc_index) return -ENOENT; dn = dlpar_configure_connector(drc_index, parent_dn); - if (!dn) + if (!dn) { + of_node_put(parent_dn); return -ENOENT; + } rc = dlpar_attach_node(dn, parent_dn); if (rc) -- 1.8.3.1