Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp273957img; Thu, 21 Mar 2019 20:08:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqwRAPN6cMHKZqVEaWjHPqYjqiWYyZ2DxgX/n7nPxQJYKVKNcLdmtcLVlPf8s1aDPqsw6mBs X-Received: by 2002:a62:2a97:: with SMTP id q145mr7008721pfq.22.1553224101320; Thu, 21 Mar 2019 20:08:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553224101; cv=none; d=google.com; s=arc-20160816; b=ljOnArU3ddYeARTp9pU8LHrUxX6Ls7CKpn0V58pKUPeIsKhf1lUxaRYdYGP0ruC7bd ahN8DCZKFbi8L7GkqE2Km6HwuVDjPRCVQVytcrVi22oSYze07wp875HYjgDXr59Egdyq zijv5VFLweFQNZmIa77MH8IoQBE7WvysydBLOoxIvvdT7stSRlaieoZJL9ZCIIAMUclY JtlDBHdIHjgmxg6BSgrHobq8W5XFexQRnhd+i+VPSnMu5bSJFeva3DfNqjh8H2x5Ai45 n/pV1p4oHFBOaGV8YHqLMIyU3xh1WmfBaXSTjBijkrlU/j+9svgUrixrAQtK59fKrocD AYow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=2JSAfPtoSYZWg0R3nZ1RMxXYyMA9QZN/v9NaUUPJups=; b=U9MwL881Uc7jNjdS6LbzxtdI/tf5OpALIQZs56V53ZDr5OqpphYugOxu0bGCt26vML +qVzR6y+JBUJr9IVMj49iqx589vqaUYQ5ifYhIYZ7OkL/zE5vUlVeCtQIA9D1nd0WaND 7TxvYohs4EObxKDFG3v9M2bwvrh5kJw5efyfumnuQgCNXrHiasIPoyWpv1HxrWdrNeQS MDYG3d3cC+io6JBSl6vsprsMpNYPnh/gIPEC/vg85eT/V8dOcxYWgp2vOkbTgzYlNMtz bgK8Ll4qK+PK8MLgFm7Dz/JcECqVBqDxWXC8rssOY96uhlytUj7vZrGobpZsnlhU5h6E pPyQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e1si5725897pgm.45.2019.03.21.20.08.03; Thu, 21 Mar 2019 20:08:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727535AbfCVDHM (ORCPT + 99 others); Thu, 21 Mar 2019 23:07:12 -0400 Received: from mxhk.zte.com.cn ([63.217.80.70]:39582 "EHLO mxhk.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727222AbfCVDHM (ORCPT ); Thu, 21 Mar 2019 23:07:12 -0400 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 69DE437EF9822F2DE665; Fri, 22 Mar 2019 11:07:10 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id x2M35kRq078031; Fri, 22 Mar 2019 11:05:46 +0800 (GMT-8) (envelope-from wen.yang99@zte.com.cn) Received: from fox-host8.localdomain ([10.74.120.8]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2019032211062248-5922967 ; Fri, 22 Mar 2019 11:06:22 +0800 From: Wen Yang To: linux-kernel@vger.kernel.org Cc: wang.yi59@zte.com.cn, Wen Yang , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , linuxppc-dev@lists.ozlabs.org Subject: [PATCH 1/5] powerpc/sparse: fix possible object reference leak Date: Fri, 22 Mar 2019 11:05:51 +0800 Message-Id: <1553223955-7350-1-git-send-email-wen.yang99@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2019-03-22 11:06:22, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2019-03-22 11:05:31, Serialize complete at 2019-03-22 11:05:31 X-MAIL: mse01.zte.com.cn x2M35kRq078031 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The call to of_find_node_by_path returns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage. Detected by coccinelle with the following warnings: ./arch/powerpc/platforms/pseries/pseries_energy.c:101:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 46, but without a corresponding object release within this function. ./arch/powerpc/platforms/pseries/pseries_energy.c:172:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 111, but without a corresponding object release within this function. Signed-off-by: Wen Yang Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org --- arch/powerpc/platforms/pseries/pseries_energy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/platforms/pseries/pseries_energy.c b/arch/powerpc/platforms/pseries/pseries_energy.c index 6ed2212..e3913e4 100644 --- a/arch/powerpc/platforms/pseries/pseries_energy.c +++ b/arch/powerpc/platforms/pseries/pseries_energy.c @@ -69,7 +69,7 @@ static u32 cpu_to_drc_index(int cpu) of_read_drc_info_cell(&info, &value, &drc); if (strncmp(drc.drc_type, "CPU", 3)) - goto err; + goto err_of_node_put; if (thread_index < drc.last_drc_index) break; @@ -131,7 +131,7 @@ static int drc_index_to_cpu(u32 drc_index) of_read_drc_info_cell(&info, &value, &drc); if (strncmp(drc.drc_type, "CPU", 3)) - goto err; + goto err_of_node_put; if (drc_index > drc.last_drc_index) { cpu += drc.num_sequential_elems; -- 2.9.5