Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3769107yba; Tue, 16 Apr 2019 19:44:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqywlNCU10EwjXjJUG781qF67oBB8obkky2V0qV/92q+nHGxhjw9WFp2wJNYddJ13LdR6rCL X-Received: by 2002:a62:524e:: with SMTP id g75mr84919744pfb.106.1555469093200; Tue, 16 Apr 2019 19:44:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555469093; cv=none; d=google.com; s=arc-20160816; b=JXMfT2AWd3AaMEp/tb0B3lZGQiHZStVwzXqoVF/I7OOr8cS+it4RKwnWOvllIRSbqQ oJjF7I5fOkgCMB+ORmv1Z7xAKb1ZaLEUwVkNuOr68koPoKEDavFYI5/oWV4AAyZ5y92Q 7A13vd1AaDCSKHTLo66EZ+jthR4vfDO0QFQl5bcIp/Aq45Ek3NJU7NKrCUdqiLS+v1YW i3ONFumZurnS91zZqgmcviuu1zoszMJGGI01mz9Y6Md9gJekQJpwr8MbHjNqDaoWR7A2 449BH5hhefb9giaz4Zo4aJe5HRChtAH/tDNavu+TGNkZ69oVyFT9vcRflds3iW+Gy+Ln 5Wbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=kKrflzj0F2ySMN+/DwrHf915OfHgPx7T6wGNMb9t0GE=; b=g5D3rZtv0MfrLo8TdOKAMJHUrradXyR1B7wC1gweOhroVSnnBYdnhVBH5kCNoKWJqV 2YhWpksyUdB+jIvm0uPbXb+BfVGTJZwlNX+aZYLoZXx+/ffG5XgcSKcbyW1Ae0nVbC2o lGik2EWSZcQWucFAcaWzQojkmoXloxXX6wl7N01duvjrPGY9Ct7MJL/y3Lc1+0mUKjM7 XwyQ4QfIecQki+B0mGaOrlIYrApyL+tyeeKiUPDH2hQAG2RNwdvZGgsNNSNIn0e1q2sM 8r8TVYydYPLKfNTFd1Enl8/4iuPr/H35GuKQ2RF3WRFLgi71MKDW80YKasPno6xOCdf8 0qqQ== 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 y2si48635682pgl.527.2019.04.16.19.44.37; Tue, 16 Apr 2019 19:44:53 -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 S1731103AbfDQCma (ORCPT + 99 others); Tue, 16 Apr 2019 22:42:30 -0400 Received: from out1.zte.com.cn ([202.103.147.172]:54986 "EHLO mxct.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728032AbfDQCm3 (ORCPT ); Tue, 16 Apr 2019 22:42:29 -0400 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id B6835BA9BFF2DA252E23; Wed, 17 Apr 2019 10:42:27 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id x3H2gKi3060602; Wed, 17 Apr 2019 10:42:20 +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 2019041710424087-8909752 ; Wed, 17 Apr 2019 10:42:40 +0800 From: Wen Yang To: linux-kernel@vger.kernel.org Cc: wang.yi59@zte.com.cn, Wen Yang , Sebastian Reichel , linux-pm@vger.kernel.org Subject: [PATCH 1/2] power: supply: fix leaked of_node refs in ab8500_bm_of_probe Date: Wed, 17 Apr 2019 10:43:02 +0800 Message-Id: <1555468983-34952-2-git-send-email-wen.yang99@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1555468983-34952-1-git-send-email-wen.yang99@zte.com.cn> References: <1555468983-34952-1-git-send-email-wen.yang99@zte.com.cn> X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2019-04-17 10:42:40, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2019-04-17 10:42:13, Serialize complete at 2019-04-17 10:42:13 X-MAIL: mse01.zte.com.cn x3H2gKi3060602 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The call to of_parse_phandle returns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage. 492 int ab8500_bm_of_probe(struct device *dev, 493 struct device_node *np, 494 struct abx500_bm_data *bm) 495 { 496 const struct batres_vs_temp *tmp_batres_tbl; 497 struct device_node *battery_node; ... 501 /* get phandle to 'battery-info' node */ 502 battery_node = of_parse_phandle(np, "battery", 0); ... 509 if (!btech) { 510 dev_warn(dev, "missing property battery-name/type\n"); 511 return -EINVAL; ---> leaked here 512 } ... 540 of_node_put(battery_node); ---> released here 541 542 return 0; 543 } Detected by coccinelle with the following warnings: ./drivers/power/supply/ab8500_bmdata.c:511:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 502, but without a corresponding object release within this function. Signed-off-by: Wen Yang Cc: Sebastian Reichel Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/power/supply/ab8500_bmdata.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/power/supply/ab8500_bmdata.c b/drivers/power/supply/ab8500_bmdata.c index 7b2b699..f6a6697 100644 --- a/drivers/power/supply/ab8500_bmdata.c +++ b/drivers/power/supply/ab8500_bmdata.c @@ -508,6 +508,7 @@ int ab8500_bm_of_probe(struct device *dev, btech = of_get_property(battery_node, "stericsson,battery-type", NULL); if (!btech) { dev_warn(dev, "missing property battery-name/type\n"); + of_node_put(battery_node); return -EINVAL; } -- 2.9.5