Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4821842ybl; Wed, 22 Jan 2020 05:24:10 -0800 (PST) X-Google-Smtp-Source: APXvYqz6CKdXE6o1mxNY+TRLtOoG67xJqK3/rwXCTpiblbwl72jmzhnp8WJMXkbPaLJ3VpCL6Rdw X-Received: by 2002:a05:6830:16d1:: with SMTP id l17mr6942757otr.21.1579699450823; Wed, 22 Jan 2020 05:24:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579699450; cv=none; d=google.com; s=arc-20160816; b=oHCQ7+k1IopPTnW1xCa+f8yIzSOb8/LGMiiLhkuLphElrC3vHJzttnFndqcR1/KHKk KFNJjOnD40T7EO54JuZNXZqWtjXB6b5iznQzkdWGjHkOSEzRPMXT03wt6PTYYI505GSk 8eGQJhG/43VMo4cx59mT1soNodIbDJ1cTVHB3yRnZXM7WDcNvdMonuF1nIl4HuCyu9hf RJnI7pUpL6PexCbgSPWDhoYTccFZojfrRArpeqrvv/20GE7CMSjIJRPsz0dS5+Z7DIKe EjllG3+7RWJ46YArYux9PkfUC/9zB6tPYIEvZncnkqxZ9iooJb8lMyNljZizJtr9ZYQc 814w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/INjc3mqaMoLJnckewKTEUsgYwFHS4QWqPgYQOrtbj4=; b=Lqoe5gkODSSv2XSf9kCThYv0fTlrz15xAI6mvjTCHTHMc5Ki13tL4WL+9MH8OFbUP1 vAcEscS8VtCs/yMF7uGX1pZRLmG4O5Il5Z6B8wzepg4AFlTmA0lVCJJpnCJpEYFDyhpF prGWkqQllvG5FSjGgJ08QTDH3g2vfII+488kIzEzpA9uV5AgPZJpOyo2fYUbxGKEhqWY CFv46MWpBOqm2KSDgNG2WCcQdSfgQCP39Dj8aD0RBzBx+oBwofE3n0avAR2wvRS6hEwh hLqq+xduDIgZR0Q10T0UwUQv4wqDGCqphTHtkcKqr/QKah6hJYnFmGleHl/MA5T08WgP yOmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=v6kLxPL+; 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 k131si20493246oia.64.2020.01.22.05.23.58; Wed, 22 Jan 2020 05:24:10 -0800 (PST) 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=@kernel.org header.s=default header.b=v6kLxPL+; 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 S1730653AbgAVNWu (ORCPT + 99 others); Wed, 22 Jan 2020 08:22:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:40652 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729425AbgAVNWr (ORCPT ); Wed, 22 Jan 2020 08:22:47 -0500 Received: from localhost (unknown [84.241.205.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8C7432468D; Wed, 22 Jan 2020 13:22:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579699367; bh=As0BFpKYdf8bREqme8P5/YpjihCcV/hXG3yG8sQOQCw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v6kLxPL+gaAoOJgZayM1q+SSKprAdO9ZbXaOUwcH4CX9DOFHtsX8P2id6ZtmERScl h2jndKqZMQPdboAZZrg/Uleuj3bXkwaL3l/rQNRThFBeN6LpvD0I006DVKZsksnkL2 bsGr9O9yhPP2t1D7iKqRT1iJnj4g+S+dk9AWR4ds= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kbuild test robot , Dan Carpenter , Krzysztof Kozlowski , Wolfram Sang Subject: [PATCH 5.4 123/222] i2c: iop3xx: Fix memory leak in probe error path Date: Wed, 22 Jan 2020 10:28:29 +0100 Message-Id: <20200122092842.556199913@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200122092833.339495161@linuxfoundation.org> References: <20200122092833.339495161@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Krzysztof Kozlowski commit e64175776d06a8ceebbfd349d7e66a4a46ca39ef upstream. When handling devm_gpiod_get_optional() errors, free the memory already allocated. This fixes Smatch warnings: drivers/i2c/busses/i2c-iop3xx.c:437 iop3xx_i2c_probe() warn: possible memory leak of 'new_adapter' drivers/i2c/busses/i2c-iop3xx.c:442 iop3xx_i2c_probe() warn: possible memory leak of 'new_adapter' Fixes: fdb7e884ad61 ("i2c: iop: Use GPIO descriptors") Reported-by: kbuild test robot Reported-by: Dan Carpenter Signed-off-by: Krzysztof Kozlowski Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/busses/i2c-iop3xx.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) --- a/drivers/i2c/busses/i2c-iop3xx.c +++ b/drivers/i2c/busses/i2c-iop3xx.c @@ -433,13 +433,17 @@ iop3xx_i2c_probe(struct platform_device adapter_data->gpio_scl = devm_gpiod_get_optional(&pdev->dev, "scl", GPIOD_ASIS); - if (IS_ERR(adapter_data->gpio_scl)) - return PTR_ERR(adapter_data->gpio_scl); + if (IS_ERR(adapter_data->gpio_scl)) { + ret = PTR_ERR(adapter_data->gpio_scl); + goto free_both; + } adapter_data->gpio_sda = devm_gpiod_get_optional(&pdev->dev, "sda", GPIOD_ASIS); - if (IS_ERR(adapter_data->gpio_sda)) - return PTR_ERR(adapter_data->gpio_sda); + if (IS_ERR(adapter_data->gpio_sda)) { + ret = PTR_ERR(adapter_data->gpio_sda); + goto free_both; + } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) {