From patchwork Mon Dec 27 12:51:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaoqian Lin X-Patchwork-Id: 12699739 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 13BD7C433EF for ; Mon, 27 Dec 2021 12:53:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=z/uYoMz++INRhSfOJQK5JWROiMgQuL6sJRDWRrEoR5M=; b=nAVd2YhpgzK+H0 xxxDleteXTy3MemmC+L/LTJK0UV4FsqUrdUiLL1IywiaOUOnmwJHLbS1qSdyj6ySzK/vJg4bg5yj2 aPZiMVFgwdk1J5b9/8cOXLR1536dmb18j0pwOCRfI3UUUVa0jsaMjQLc87b98lgodde7PKGlG7ebP NvHvEut33E6ZHUUxWoTJUa/X9XxHB25bhqzxfzrWgN9GSP6C+h9aBan9e25A+idfXPHDAzbuyq9hA YY3ibxX+DWLg8pw7zfb7WpSTQzJvbDGVBxrdFJV4yV8IgN9FFhbHEZlj3gTy9OcLRIoYmIiXs0tRd 0rzb7uFbN72OlAm00Eaw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n1pTy-00GjIV-Fk; Mon, 27 Dec 2021 12:52:07 +0000 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n1pTu-00GjGO-CA for linux-arm-kernel@lists.infradead.org; Mon, 27 Dec 2021 12:52:03 +0000 Received: by mail-pg1-x535.google.com with SMTP id r5so13477845pgi.6 for ; Mon, 27 Dec 2021 04:52:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id; bh=9aFYPZXKzmDafO2auf3/6QRn9QC7vq8i5WcA0Y9xZ6c=; b=pRyt+gp3oWA47u6eHT7L7R1wOPjSAH54JQ2M5Aze4aIMLsymngl8aOnCELtOjPNDGb roNj1t+86vHcnZmL4oE2QACOyoGclGLCWZ4SzM3mB30keOvKOnOVTytxhMqInK77f8Ua PpvjzT6X/XLyRJJrMyIWuLl3qJzC4jhr1shOwGomSnOtmgwgrL+22UtLUBvwJHhByJh8 nVB8H3uCPueHt8vjz0YZAJykx6q/8HdFvR0kGapSPFR1UcnJqNtvc3u/jLK+1PlDbD2Q OFUdTzuU213cKbgOyzbrF8OdnmXPJ43AEEK0W1qEA6ADyxqob7IUB3Dlu9p0mXMa1LCA ln1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=9aFYPZXKzmDafO2auf3/6QRn9QC7vq8i5WcA0Y9xZ6c=; b=57NHIUHbqXWTi7N7JkDa4ksF/QQH8olZntUjSYooUfWbUbkXFCzPYArhwiAddDgFAH AGk8kByulkICPQ/t6xEM9e1s/3LYUOpcaeQV13ly6GJ2zJXG+gdwJYcbMcdZhIs/QJRx K97d6Vcl9jFGFFe3+U+a4eXOLnK+6Rk/P9OLcJhn1CqFa86nF991U3e1McGGIEp63GHx 3Ssl5vMi+p0/MQg8q6mqNYIziM7Euug9wNzyqENZ32NtQMhS9yYpfcToKMH90Yi/fdpB 3nBqemHsTbKkblRjSxaczKhslrGebN6A7OBmFCvttOvP5FeG9XX18IM8PORzkLCK9Ce5 qn8A== X-Gm-Message-State: AOAM5302NuqNXSlWrqgbZoavYNxqIWfupoikwxPae52yAcw6nBrqbYEU 5IY6iRfO9MrcK5GthZnwhYs= X-Google-Smtp-Source: ABdhPJx4bN/IiaNPezTWFQQgvtoj8yn9Dh1+jkgDDGKUqVrkqM2F0/V+u1pZgJW7kMOnbicEryw2Ug== X-Received: by 2002:a63:af19:: with SMTP id w25mr15608279pge.438.1640609520971; Mon, 27 Dec 2021 04:52:00 -0800 (PST) Received: from localhost.localdomain ([159.226.95.43]) by smtp.googlemail.com with ESMTPSA id q16sm13305049pfu.31.2021.12.27.04.51.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Dec 2021 04:52:00 -0800 (PST) From: Miaoqian Lin To: Cc: linmq006@gmail.com, Daniel Mack , Haojian Zhuang , Robert Jarzmik , Russell King , Marc Zyngier , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] ARM: pxa: Fix error handling in viper_tpm_init Date: Mon, 27 Dec 2021 12:51:53 +0000 Message-Id: <20211227125154.3145-1-linmq006@gmail.com> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211227_045202_436740_9FB9EC99 X-CRM114-Status: GOOD ( 12.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org tpm_device get by platform_device_alloc(), which calls device_initialize. Call platform_device_put(tpm_device) instead of kfree(tmp_device) to prevent memory leak. Fixes: 352699a ("Basic support for the Arcom/Eurotech Viper SBC.") Signed-off-by: Miaoqian Lin --- arch/arm/mach-pxa/viper.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-pxa/viper.c b/arch/arm/mach-pxa/viper.c index 3aa34e9a15d3..9a0f184dbecb 100644 --- a/arch/arm/mach-pxa/viper.c +++ b/arch/arm/mach-pxa/viper.c @@ -815,11 +815,11 @@ static void __init viper_tpm_init(void) sizeof(i2c_tpm_data))) { if (platform_device_add(tpm_device)) { errstr = "register TPM i2c bus"; - goto error_free_tpm; + goto exit_put_device; } } else { errstr = "allocate TPM i2c bus data"; - goto error_free_tpm; + goto exit_put_device; } } else { errstr = "allocate TPM i2c device"; @@ -827,9 +827,8 @@ static void __init viper_tpm_init(void) } return; - -error_free_tpm: - kfree(tpm_device); +exit_put_device: + platform_device_put(tpm_device); error_tpm: pr_err("viper: Couldn't %s, giving up\n", errstr); }