From nobody Fri Apr 3 08:17:52 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D9D5ECAAD3 for ; Wed, 14 Sep 2022 03:20:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229577AbiINDUJ (ORCPT ); Tue, 13 Sep 2022 23:20:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229605AbiINDUF (ORCPT ); Tue, 13 Sep 2022 23:20:05 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B84A27DF1 for ; Tue, 13 Sep 2022 20:20:01 -0700 (PDT) Received: from dggpeml500020.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MS5816k91zlVjq; Wed, 14 Sep 2022 11:16:01 +0800 (CST) Received: from dggpeml500010.china.huawei.com (7.185.36.155) by dggpeml500020.china.huawei.com (7.185.36.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 14 Sep 2022 11:19:59 +0800 Received: from huawei.com (10.67.175.33) by dggpeml500010.china.huawei.com (7.185.36.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 14 Sep 2022 11:19:59 +0800 From: Lin Yujun To: , , , , CC: , Subject: [PATCH -next] viper_tpm_init(): fix memleak on registration failure Date: Wed, 14 Sep 2022 11:16:24 +0800 Message-ID: <20220914031624.93031-1-linyujun809@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.67.175.33] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpeml500010.china.huawei.com (7.185.36.155) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In case device registration fails, the platform device structure needs to be free. Use platform_device_put() to free all resources instead of using kfree to release the platform device. Fixes: 352699a3d7cc ("Basic support for the Arcom/Eurotech Viper SBC.") Signed-off-by: Lin Yujun --- arch/arm/mach-pxa/viper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-pxa/viper.c b/arch/arm/mach-pxa/viper.c index 5b43351ee840..44b2c54fb2c7 100644 --- a/arch/arm/mach-pxa/viper.c +++ b/arch/arm/mach-pxa/viper.c @@ -829,7 +829,7 @@ static void __init viper_tpm_init(void) return; =20 error_free_tpm: - kfree(tpm_device); + platform_device_put(tpm_device); error_tpm: pr_err("viper: Couldn't %s, giving up\n", errstr); } --=20 2.17.1