Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp2008753pxa; Sat, 29 Aug 2020 10:51:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMSKmOKhrZ3HX/KplY3gJfhWsx47hdzofFoXHUwsrwFrOhjfEu2d7+yP/1tqVhlFvFiJNO X-Received: by 2002:a17:906:3a85:: with SMTP id y5mr4343148ejd.507.1598723467502; Sat, 29 Aug 2020 10:51:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598723467; cv=none; d=google.com; s=arc-20160816; b=xqQ9CQazqQC/6zTG4fyw4KNG0+mw8UXP/EDHa+/t3OaoGLLy2bpj+aAM0u+JoNwuBb VVzGSdjyw/I0esRfBk+vlVnSol4z0ZHtncRjFBwThkzyHHmVxbXKZMk1/BBkXFdm3XGT +ihMvEwdRyZC8yzWo+a05sNiEaIrjKZ1+aT43VfhsiacVQiFIYsseJDXQSozCK6nT952 UL0JrQLyZtTBcE0lcW0UpwcW8iQpy8X4IeZQk+qBGfy4EPDZT3vOENTjVF92XPX+Z1Op jYU8ZwkZg5eagY14O5QSbmv/f0Ac+oilrbrkSEeRVDnx/sS34DSZaNy7QNXC74uIiOi0 RaOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=KsaJIKVvAHoJAzrvMMfIyLvbZDHvGrzugzw5X7p4pTM=; b=m7URmmqKCTO14J2e7bjVWkHqHvoUhQ7ER2V3SErgRxvoLKRwXG/yWEcax5U5mIm2l8 Txjgvi1I2yLEHyJZ519ekS3tdrYoNfdKGNnzpSM+WFGeyFovlkKg4Hky5kx8OkQRzxrw MMUyocNbhNfyPtXWH+X82fuNLxqZtG17rcjeVa3mZS4VsB8hkO+RuJnOjx9iAsyRyMay 0+M/pCnXlH2xb0A/pkW3T6Rud+5sRe75rbOK/0hj/CpUT9ZIr/y2WolctFDCX85az232 xc17x5Rfv15JSCmz2a3DW7S8jMLuBRVLI1+vsr33qSmG5/DvG3D7Cf0SoeSXkqzcJTet f7ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iTuty6GI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t27si2144382ejf.672.2020.08.29.10.50.43; Sat, 29 Aug 2020 10:51:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iTuty6GI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728284AbgH2RuF (ORCPT + 99 others); Sat, 29 Aug 2020 13:50:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728203AbgH2RuC (ORCPT ); Sat, 29 Aug 2020 13:50:02 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5FCAC061236; Sat, 29 Aug 2020 10:50:01 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id 17so2296460pfw.9; Sat, 29 Aug 2020 10:50:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=KsaJIKVvAHoJAzrvMMfIyLvbZDHvGrzugzw5X7p4pTM=; b=iTuty6GIFSuRMA5BcteOTBIT1C9WOPlxcD/frG0pI7W9r7WEENne7mQpiH3p2scm1T 0L+n0mtJSzbEkwbS7ueauX6kZVSjAAGy8zlHcqL59Khme7bV7i03JNTNhayQDXV+B4vr aXD2Uket3FikC3OAJzjlPF/FdPZu/z3SDfXGE2f+78LNW32PSZHfep24Rfze26+M814W 2iztZfyZ8IzUfS0me555OwPyff0b1GOK+nk4IDrEXyC3KgeaWMD6go1whlSCCzuKnumt 82ictxdj6rZs6Jiu0buiCiyVpjrWWi80UACHUSwSJCixtgwwrokaKwHb26OQti6Ge9C9 l47g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=KsaJIKVvAHoJAzrvMMfIyLvbZDHvGrzugzw5X7p4pTM=; b=UdTYVxr3DbIXEp+aWgl1EtKCKvRsLgHp3q0MbqmBIJ8eIOwp2ZWdosoGd4Yc8LMi3Z po5PI8rmHlGmwh7sG6QrL6rRb4vEhIUOB/RnAc/ds6hnESH1hhEuupGMNBZERDzvM+pB 6RXiVAPgA/ebG2ps91WUu+fVN1ygIk2wtEN/SoXgnNceXZ9oj3zetTz36vOrFHe2Xj5a bcjL+kAyA3gqw7ljAp/IKN2XnXI7wPC8312xX6UyYT/vjL9+3/ZWQ1PWLPA3Hb4BYTcF XKJ9DdW7nTXgMz9OOXTgoRmh8lpqXQnmxJL1dvgel/+yvOoFeNT74FUPy2RBA+Asns6g XG0w== X-Gm-Message-State: AOAM532VFcst/teaEGg9KU0NoRUg1IQlk4905b2/lmz20jUNnnJn2V2/ k6SbWcyNwQhkd20/YHr9Rxk= X-Received: by 2002:a63:f09:: with SMTP id e9mr3181138pgl.334.1598723401132; Sat, 29 Aug 2020 10:50:01 -0700 (PDT) Received: from Kaladin ([49.207.221.164]) by smtp.gmail.com with ESMTPSA id q11sm2948848pgj.92.2020.08.29.10.49.58 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 29 Aug 2020 10:50:00 -0700 (PDT) Date: Sat, 29 Aug 2020 23:19:56 +0530 From: Sumera Priyadarsini To: agross@kernel.org Cc: bjorn.andersson@linaro.org, Julia.Lawall@lip6.fr, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] bus: qcom-ebi2: Add of_node_put() before return statement Message-ID: <20200829174956.GA10245@Kaladin> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Every iteration of for_each_available_child_of_node() decrements the reference count of the previous node, however when control is transferred from the middle of the loop, as in the case of a return or break or goto, there is no decrement thus ultimately resulting in a memory leak. Fix a potential memory leak in qcom-ebi2.c by inserting of_node_put() before a return statement. Issue found with Coccinelle. Signed-off-by: Sumera Priyadarsini --- drivers/bus/qcom-ebi2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/bus/qcom-ebi2.c b/drivers/bus/qcom-ebi2.c index 03ddcf426887..0b8f53a688b8 100644 --- a/drivers/bus/qcom-ebi2.c +++ b/drivers/bus/qcom-ebi2.c @@ -353,8 +353,10 @@ static int qcom_ebi2_probe(struct platform_device *pdev) /* Figure out the chipselect */ ret = of_property_read_u32(child, "reg", &csindex); - if (ret) + if (ret) { + of_node_put(child); return ret; + } if (csindex > 5) { dev_err(dev, -- 2.17.1