diff mbox

[cbootimage] bct_dump: don't crash on devices without RSA support

Message ID 20160728174405.16136-1-swarren@wwwdotorg.org
State Deferred
Headers show

Commit Message

Stephen Warren July 28, 2016, 5:44 p.m. UTC
From: Stephen Warren <swarren@nvidia.com>

format_rsa_param() currently crashes on chips that don't implement
soc_config->get_value_size(); that is, on all chips before T124. Fix the
function not to crash. Better might be to avoid even dumping RSA
parameters on chips which don't support RSA, but that's a larger change
that needs much more work.

Fixes: 3c3b992a6814 ("Add support to dump rsa related fields for t210")
Cc: Jimmy Zhang <jimmzhang@nvidia.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 src/bct_dump.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Stephen Warren July 29, 2016, 4:07 p.m. UTC | #1
On 07/28/2016 11:44 AM, Stephen Warren wrote:
> From: Stephen Warren <swarren@nvidia.com>
>
> format_rsa_param() currently crashes on chips that don't implement
> soc_config->get_value_size(); that is, on all chips before T124. Fix the
> function not to crash. Better might be to avoid even dumping RSA
> parameters on chips which don't support RSA, but that's a larger change
> that needs much more work.
>
> Fixes: 3c3b992a6814 ("Add support to dump rsa related fields for t210")
> Cc: Jimmy Zhang <jimmzhang@nvidia.com>
> Signed-off-by: Stephen Warren <swarren@nvidia.com>

I've applied this.
--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/src/bct_dump.c b/src/bct_dump.c
index 4f50fa261e6e..b4ca9fcff0ef 100644
--- a/src/bct_dump.c
+++ b/src/bct_dump.c
@@ -133,10 +133,14 @@  static void format_rsa_param(parse_token id, char const * message, void * data)
 {
 #define MAX_BYTE_NUMBER_PER_LINE	16
 	u_int8_t *rsa = (u_int8_t *)data;
-	int size = g_soc_config->get_value_size(id);
-	int byte_index;
+	int size, byte_index;
 
 	printf("%s", message);
+
+	if (!g_soc_config->get_value_size)
+		return;
+
+	size = g_soc_config->get_value_size(id);
 	for (byte_index = 0; byte_index < size; ++byte_index) {
 		printf(" %02x", *rsa++);