Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp98487yba; Thu, 11 Apr 2019 23:02:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqwma2RWmv+H/OucaJqr9vX9ghIgd9JKTqZTR9p1sBGjUhdkF8+HzX+wrMpaXlMRM0jlgEMu X-Received: by 2002:a17:902:e407:: with SMTP id ci7mr54636018plb.219.1555048953994; Thu, 11 Apr 2019 23:02:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555048953; cv=none; d=google.com; s=arc-20160816; b=h4mc/HFH/y7idEVhl3Ay5koLbl7rWMXwkkwSdOkee/J/U4UNhkDMaUYnUXGvygF2Vg MQN2fIVIcv6BRDYgrQO0SV24bJaOj3yOwZQb/NqzRTVMMOtYTnbGuCZaBns7nL9vk3d5 MHucr1/IBIfegxYFnFru/9NVD+wc+8nw9OutnnCIpGcOgWC6k5ICEhOa8qfa+9KzQxcx 70AvvvqVY74D8odGPb06ezW2zRbulULd9xQ7t3xw+gtUkGlKo1Y5gQ0fCbkv6AG5fvAs qGKNXtU7gxAXjEaTr7omM81lvVUY8JMfoH76GPa7hVYoRE3mwVtih9lSdoRHwVyPKXm8 MPzQ== 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=Iqgrb3ojcokgC7wfGka0Ynxlvw41ZR0oTBfHaiXEW78=; b=vkX/i6Xg/jplyFgvwCU08NMmJJbPJ/1o1DLnsgkf5fCVPmJfe2Q8Z6ZnvlLXqQpFnQ RV1LCukyEsB6WHOZqRj4sz5h+P06X8uRcB7lZ0TCynKfC1lyRSsQQBAf9AoWdAy3Vi+g Zd+7m28XePZIu4akc+wwKWUllakUfz3nACn3EGtnWSefFH0GNrXY0rPBc7ZW9epBcWIZ NY0NpQksSxLoCZvbKvrjv0SVxqQBruGi9IUPbbW8wOPRAvFKTKSB5X5X5it8vM+FkLlf TgQcGWRDzBb2VUTCVzHqS9B+PtWXy3RYyurCSoFoR0SjnF9WzoCR396DMKvdYGaK26VV C7/Q== 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 f3si18357770plr.136.2019.04.11.23.02.18; Thu, 11 Apr 2019 23:02:33 -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 S1726921AbfDLGBl (ORCPT + 99 others); Fri, 12 Apr 2019 02:01:41 -0400 Received: from mxhk.zte.com.cn ([63.217.80.70]:30332 "EHLO mxhk.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726876AbfDLGBh (ORCPT ); Fri, 12 Apr 2019 02:01:37 -0400 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 9879E1CF80F00DE50E5E; Fri, 12 Apr 2019 14:01:35 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id x3C61QxU088863; Fri, 12 Apr 2019 14:01:26 +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 2019041214020559-8432938 ; Fri, 12 Apr 2019 14:02:05 +0800 From: Wen Yang To: linux-kernel@vger.kernel.org Cc: wang.yi59@zte.com.cn, Wen Yang , Patrice Chotard , Linus Walleij , linux-gpio@vger.kernel.org Subject: [PATCH 3/5] pinctrl: st: fix leaked of_node references Date: Fri, 12 Apr 2019 14:02:21 +0800 Message-Id: <1555048943-39589-4-git-send-email-wen.yang99@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1555048943-39589-1-git-send-email-wen.yang99@zte.com.cn> References: <1555048943-39589-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-12 14:02:05, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2019-04-12 14:01:12, Serialize complete at 2019-04-12 14:01:12 X-MAIL: mse01.zte.com.cn x3C61QxU088863 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The call to of_get_child_by_name returns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage. Detected by coccinelle with the following warnings: ./drivers/pinctrl/pinctrl-st.c:1188:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1175, but without a corresponding object release within this function. ./drivers/pinctrl/pinctrl-st.c:1188:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1175, but without a corresponding object release within this function. ./drivers/pinctrl/pinctrl-st.c:1199:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1175, but without a corresponding object release within this function. ./drivers/pinctrl/pinctrl-st.c:1199:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1175, but without a corresponding object release within this function. Signed-off-by: Wen Yang Cc: Patrice Chotard Cc: Linus Walleij Cc: linux-gpio@vger.kernel.org Cc: linux-kernel@vger.kernel.org (open list) --- drivers/pinctrl/pinctrl-st.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c index e66af93..195b442 100644 --- a/drivers/pinctrl/pinctrl-st.c +++ b/drivers/pinctrl/pinctrl-st.c @@ -1170,7 +1170,7 @@ static int st_pctl_dt_parse_groups(struct device_node *np, struct property *pp; struct st_pinconf *conf; struct device_node *pins; - int i = 0, npins = 0, nr_props; + int i = 0, npins = 0, nr_props, ret = 0; pins = of_get_child_by_name(np, "st,pins"); if (!pins) @@ -1185,7 +1185,8 @@ static int st_pctl_dt_parse_groups(struct device_node *np, npins++; } else { pr_warn("Invalid st,pins in %pOFn node\n", np); - return -EINVAL; + ret = -EINVAL; + goto out_put_node; } } @@ -1195,8 +1196,10 @@ static int st_pctl_dt_parse_groups(struct device_node *np, grp->pin_conf = devm_kcalloc(info->dev, npins, sizeof(*conf), GFP_KERNEL); - if (!grp->pins || !grp->pin_conf) - return -ENOMEM; + if (!grp->pins || !grp->pin_conf) { + ret = -ENOMEM; + goto out_put_node; + } /* */ for_each_property_of_node(pins, pp) { @@ -1229,9 +1232,11 @@ static int st_pctl_dt_parse_groups(struct device_node *np, } i++; } + +out_put_node: of_node_put(pins); - return 0; + return ret; } static int st_pctl_parse_functions(struct device_node *np, -- 2.9.5