public inbox for linux-crypto@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: hisilicon/hpre - Fix a erroneous check after snprintf()
@ 2023-09-04 20:17 Christophe JAILLET
  2023-09-05  2:27 ` Herbert Xu
  2023-09-15 10:43 ` Herbert Xu
  0 siblings, 2 replies; 13+ messages in thread
From: Christophe JAILLET @ 2023-09-04 20:17 UTC (permalink / raw)
  To: Longfang Liu, Herbert Xu, David S. Miller, Zaibo Xu
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-crypto

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);
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2023-09-15 10:44 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-04 20:17 [PATCH] crypto: hisilicon/hpre - Fix a erroneous check after snprintf() Christophe JAILLET
2023-09-05  2:27 ` Herbert Xu
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox