From: Christophe JAILLET Date: Mon, 4 Sep 2023 20:17:29 +0000 (+0200) Subject: crypto: hisilicon/hpre - Fix a erroneous check after snprintf() X-Git-Tag: v6.7-rc1~91^2~261 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c977950146720abff14e46d8c53f5638b06a9182;p=thirdparty%2Fkernel%2Flinux.git crypto: hisilicon/hpre - Fix a erroneous check after snprintf() 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 Signed-off-by: Herbert Xu --- diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/hisilicon/hpre/hpre_main.c index 39297ce70f441..db44d889438a6 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);