From patchwork Sun Aug 18 09:39:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 171569 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1586524ily; Sun, 18 Aug 2019 02:39:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqwJcAuXB0MDOvlIYObEYE9j9bVZqyQ5nPR8Jg2CgdA+6Lugf8EcSlhFpKYsb3EuGUO5a7sf X-Received: by 2002:a17:90a:17e2:: with SMTP id q89mr15676281pja.8.1566121181831; Sun, 18 Aug 2019 02:39:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566121181; cv=none; d=google.com; s=arc-20160816; b=0wPltweQjexOjbmC2F0dmRmCIVyB3s+JNMRcRUV5KmGvVyi7eaA2v5Rq8mKZG5wDBt U62xvOg2dRgsIgy89pHE5kL+wLHaeL19gKOlrhExtFfqUcUgpDG8pG5przqs/i1sjbvD ylw7Skd+2Qgl7ct0CO2XpMqqsHoEmrn69Zvv9Yiz0P6Y/0YFCUu7Z3rPD9R7x544RRjw cjf2uLcJNTNtHEqJVunMsGfp4AYcDdRPsrIbo2b0DwnrZBVtBCUvUj6XCBXgaP3FQ5SI SKLTtREAtlfC5Wfad1CbvC5u/ol1bEbnRR1mAJdmJIQXqGifpSPouOEtopDoCK8+46cF o0TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LxvxKTPsHiH7UyfUtgY+QrOf6MaZaGNFhraZnj8cu+w=; b=VHW7UvDtF7V+T4Dhkd9T4b1T7yI/24/6DCjsh/df0vJ/yCHVRNGbo+hZIOvke3NMFp oY4iJTbV0oFKLxo1NcH1e5g0N4pyC86QIjxdgPbL/UWSpK5bFq2SMIEe+s+kTMwlajbt GRDtCg+ylbqi1MQH9ix7smcmvheA0pfEXiLvxC3ihbiLB+0IxSKdOshQC6F1KkaqXndX WWnZIUtWoAp6ttqCfVe8DHhx667vIU6RfW2ZtBi01nZxAEyrhS/rRJ9tOwStUfDteBjp +Flj17gJ078mRfvBeCw1qkphNUH2LyRGpEpBE7YsZeYWV+IDbH1PhRf8DYPL47DAC+jh 3W8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kBpAVqCh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 186si8027837pfd.44.2019.08.18.02.39.41; Sun, 18 Aug 2019 02:39:41 -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; dkim=pass header.i=@linaro.org header.s=google header.b=kBpAVqCh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726668AbfHRJjh (ORCPT + 28 others); Sun, 18 Aug 2019 05:39:37 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:46449 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726115AbfHRJjf (ORCPT ); Sun, 18 Aug 2019 05:39:35 -0400 Received: by mail-wr1-f67.google.com with SMTP id z1so5624174wru.13 for ; Sun, 18 Aug 2019 02:39:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LxvxKTPsHiH7UyfUtgY+QrOf6MaZaGNFhraZnj8cu+w=; b=kBpAVqChwEj7CrYLYsV9bO+MmvHHN4/ns32u8ZjkZBg5oUYPHdHEQ5tBdamPXCnYO6 unlnqHRujP58MV9zddJB+YEFtAEKlDwbDUlWCC3cAJIKWyHfcYRcYjziJBeWOuRUXnQ8 MvSUSy6HG3IUSojO7yDeFwM9W7gLEG8P5iy7szskAyTiUHAROVUxd54QsrkMhri/rJyR 1s+1AXo/+qfUofTP3inpaMP9QiQS3Ed9S7/DXxg+dI1cBlRyksJ6/hWun8S5cInaEztp P2KC/8Qlm8787ff17y3K8Oc+7Ods1Ss6qhEzCGv83jLAOtVqziL48K2CHEO89XNXdzBN uwHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LxvxKTPsHiH7UyfUtgY+QrOf6MaZaGNFhraZnj8cu+w=; b=O2eSNSjfkXVPJSZ6ysEeTOl49qU8IZnd+sl9w4JDX1DgpJ9bagCtlsqlImyhq0KMZl MnTGHSkOTtXlhf6LlQJGcpM7DgMqq5LPCUZHNDW3RX8SKzuVl+naX98O49/ZQ2/Q7p8A NRhNYMe3vKEIj5n52oUE5xyMtq2IOv03t8C6dgmQkaBp/7qYf0iLTbufBbgUt7oysBBU qEoPiQWefpletmA/0Dg6PBzhrkc+SFFpIVhshWFdVk8132YlUuKxpT4GjhIz8fu+7oIK n+CpNQcjdMvnc5BcKh7Pph0dbpl0YOA/g8igO/Dx7s+tbxb4Zcsf8NkQH0YvLwvgGgNj BnOw== X-Gm-Message-State: APjAAAXCdcVQt3gMEVVa2MkkQx7KdINTQxMogbAXHk/0JtaPbx1ODCrC u4K/nHh5Yp5rw9ZadGGPrv8LCg== X-Received: by 2002:a5d:4ecb:: with SMTP id s11mr12491768wrv.323.1566121173145; Sun, 18 Aug 2019 02:39:33 -0700 (PDT) Received: from srini-hackbox.lan (cpc89974-aztw32-2-0-cust43.18-1.cable.virginm.net. [86.30.250.44]) by smtp.gmail.com with ESMTPSA id q3sm11520190wma.48.2019.08.18.02.39.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2019 02:39:32 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Nishka Dasgupta , Bjorn Andersson , Srinivas Kandagatla Subject: [PATCH 1/2] slimbus: qcom-ngd-ctrl: Add of_node_put() before return Date: Sun, 18 Aug 2019 10:39:01 +0100 Message-Id: <20190818093902.29993-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190818093902.29993-1-srinivas.kandagatla@linaro.org> References: <20190818093902.29993-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nishka Dasgupta Each iteration of for_each_available_child_of_node puts the previous node, but in the case of a return from the middle of the loop, there is no put, thus causing a memory leak. Hence add an of_node_put before the return in two places. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Reviewed-by: Bjorn Andersson Signed-off-by: Srinivas Kandagatla --- drivers/slimbus/qcom-ngd-ctrl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 2.21.0 diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd-ctrl.c index f3585777324c..29fbab55c3b3 100644 --- a/drivers/slimbus/qcom-ngd-ctrl.c +++ b/drivers/slimbus/qcom-ngd-ctrl.c @@ -1338,12 +1338,15 @@ static int of_qcom_slim_ngd_register(struct device *parent, continue; ngd = kzalloc(sizeof(*ngd), GFP_KERNEL); - if (!ngd) + if (!ngd) { + of_node_put(node); return -ENOMEM; + } ngd->pdev = platform_device_alloc(QCOM_SLIM_NGD_DRV_NAME, id); if (!ngd->pdev) { kfree(ngd); + of_node_put(node); return -ENOMEM; } ngd->id = id;