From: Herbert Xu <herbert@gondor.apana.org.au>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Longfang Liu <liulongfang@huawei.com>,
"David S. Miller" <davem@davemloft.net>,
Zaibo Xu <xuzaibo@huawei.com>,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
linux-crypto@vger.kernel.org
Subject: Re: [PATCH] crypto: hisilicon/hpre - Fix a erroneous check after snprintf()
Date: Tue, 5 Sep 2023 10:27:20 +0800 [thread overview]
Message-ID: <ZPaSCOX1F9b36rxV@gondor.apana.org.au> (raw)
In-Reply-To: <73534cb1713f58228d54ea53a8a137f4ef939bad.1693858632.git.christophe.jaillet@wanadoo.fr>
On Mon, Sep 04, 2023 at 10:17:29PM +0200, Christophe JAILLET wrote:
> This error handling looks really strange.
> Check if the string has been truncated instead.
>
> Fixes: 02ab994635eb ("crypto: hisilicon - Fixed some tiny bugs of HPRE")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> drivers/crypto/hisilicon/hpre/hpre_main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/hisilicon/hpre/hpre_main.c
> index 39297ce70f44..db44d889438a 100644
> --- a/drivers/crypto/hisilicon/hpre/hpre_main.c
> +++ b/drivers/crypto/hisilicon/hpre/hpre_main.c
> @@ -1033,7 +1033,7 @@ static int hpre_cluster_debugfs_init(struct hisi_qm *qm)
>
> for (i = 0; i < clusters_num; i++) {
> ret = snprintf(buf, HPRE_DBGFS_VAL_MAX_LEN, "cluster%d", i);
> - if (ret < 0)
> + if (ret >= HPRE_DBGFS_VAL_MAX_LEN)
> return -EINVAL;
> tmp_d = debugfs_create_dir(buf, qm->debug.debug_root);
Who is going to free the allocated memory in case of error?
The other snprintf in the same file also looks suspect.
Thanks,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
next prev parent reply other threads:[~2023-09-05 16:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-04 20:17 [PATCH] crypto: hisilicon/hpre - Fix a erroneous check after snprintf() Christophe JAILLET
2023-09-05 2:27 ` Herbert Xu [this message]
2023-09-05 5:27 ` Marion & Christophe JAILLET
2023-09-05 8:17 ` Herbert Xu
2023-09-06 2:04 ` liulongfang
2023-09-08 16:11 ` Christophe JAILLET
2023-09-11 1:52 ` liulongfang
2023-09-07 11:15 ` Dan Carpenter
2023-09-11 1:58 ` liulongfang
2023-09-11 7:27 ` Dan Carpenter
2023-09-12 6:39 ` Dan Carpenter
2023-09-12 10:05 ` Herbert Xu
2023-09-15 10:43 ` Herbert Xu
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=ZPaSCOX1F9b36rxV@gondor.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=christophe.jaillet@wanadoo.fr \
--cc=davem@davemloft.net \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liulongfang@huawei.com \
--cc=xuzaibo@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox