Commit d634baea authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Herbert Xu

crypto: ccp - avoid uninitialized variable warning

The added support for version 5 CCPs introduced a false-positive
warning in the RSA implementation:

drivers/crypto/ccp/ccp-ops.c: In function 'ccp_run_rsa_cmd':
drivers/crypto/ccp/ccp-ops.c:1856:3: error: 'sb_count' may be used uninitialized in this function [-Werror=maybe-uninitialized]

This changes the code in a way that should make it easier for
the compiler to track the state of the sb_count variable, and
avoid the warning.

Fixes: 6ba46c7d ("crypto: ccp - Fix base RSA function for version 5 CCPs")
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Reviewed-by: default avatarGary R Hook <gary.hook@amd.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent c871c10e
...@@ -1785,6 +1785,7 @@ static int ccp_run_rsa_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) ...@@ -1785,6 +1785,7 @@ static int ccp_run_rsa_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)
o_len = 32 * ((rsa->key_size + 255) / 256); o_len = 32 * ((rsa->key_size + 255) / 256);
i_len = o_len * 2; i_len = o_len * 2;
sb_count = 0;
if (cmd_q->ccp->vdata->version < CCP_VERSION(5, 0)) { if (cmd_q->ccp->vdata->version < CCP_VERSION(5, 0)) {
/* sb_count is the number of storage block slots required /* sb_count is the number of storage block slots required
* for the modulus. * for the modulus.
...@@ -1879,7 +1880,7 @@ static int ccp_run_rsa_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) ...@@ -1879,7 +1880,7 @@ static int ccp_run_rsa_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)
ccp_dm_free(&exp); ccp_dm_free(&exp);
e_sb: e_sb:
if (cmd_q->ccp->vdata->version < CCP_VERSION(5, 0)) if (sb_count)
cmd_q->ccp->vdata->perform->sbfree(cmd_q, op.sb_key, sb_count); cmd_q->ccp->vdata->perform->sbfree(cmd_q, op.sb_key, sb_count);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment