From: Jarkko Sakkinen <jarkko@kernel.org>
To: Yuan Can <yuancan@huawei.com>
Cc: peterhuewe@gmx.de, jgg@ziepe.ca, sumit.garg@linaro.org,
jens.wiklander@linaro.org, maxim.uvarov@linaro.org,
linux-integrity@vger.kernel.org
Subject: Re: [PATCH] tpm/tpm_ftpm_tee: Fix error handling in ftpm_mod_init()
Date: Mon, 28 Nov 2022 03:23:16 +0200 [thread overview]
Message-ID: <Y4QNhBTwC9M9hXm4@kernel.org> (raw)
In-Reply-To: <20221124031926.16963-1-yuancan@huawei.com>
On Thu, Nov 24, 2022 at 03:19:26AM +0000, Yuan Can wrote:
> The ftpm_mod_init() returns the driver_register() directly without checking
> its return value, if driver_register() failed, the ftpm_tee_plat_driver is
> not unregistered.
>
> Fix by unregister ftpm_tee_plat_driver when driver_register() failed.
>
> Fixes: 9f1944c23c8c ("tpm_ftpm_tee: register driver on TEE bus")
> Signed-off-by: Yuan Can <yuancan@huawei.com>
> ---
> drivers/char/tpm/tpm_ftpm_tee.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/char/tpm/tpm_ftpm_tee.c b/drivers/char/tpm/tpm_ftpm_tee.c
> index 5c233423c56f..deff23bb54bf 100644
> --- a/drivers/char/tpm/tpm_ftpm_tee.c
> +++ b/drivers/char/tpm/tpm_ftpm_tee.c
> @@ -397,7 +397,13 @@ static int __init ftpm_mod_init(void)
> if (rc)
> return rc;
>
> - return driver_register(&ftpm_tee_driver.driver);
> + rc = driver_register(&ftpm_tee_driver.driver);
> + if (rc) {
> + platform_driver_unregister(&ftpm_tee_plat_driver);
> + return rc;
> + }
> +
> + return 0;
> }
>
> static void __exit ftpm_mod_exit(void)
> --
> 2.17.1
>
Acked-by: Jarkko Sakkinen <jarkko@kernel.org>
BR, Jarkko
next prev parent reply other threads:[~2022-11-28 1:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-24 3:19 [PATCH] tpm/tpm_ftpm_tee: Fix error handling in ftpm_mod_init() Yuan Can
2022-11-28 1:23 ` Jarkko Sakkinen [this message]
2022-11-28 6:42 ` Maxim Uvarov
2022-12-04 16:59 ` Jarkko Sakkinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y4QNhBTwC9M9hXm4@kernel.org \
--to=jarkko@kernel.org \
--cc=jens.wiklander@linaro.org \
--cc=jgg@ziepe.ca \
--cc=linux-integrity@vger.kernel.org \
--cc=maxim.uvarov@linaro.org \
--cc=peterhuewe@gmx.de \
--cc=sumit.garg@linaro.org \
--cc=yuancan@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.