From patchwork Thu Jul 28 17:44:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Warren X-Patchwork-Id: 653832 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3s0fPW3Xknz9t1F for ; Fri, 29 Jul 2016 03:44:31 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161134AbcG1Ro0 (ORCPT ); Thu, 28 Jul 2016 13:44:26 -0400 Received: from avon.wwwdotorg.org ([70.85.31.133]:51258 "EHLO avon.wwwdotorg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161132AbcG1RoZ (ORCPT ); Thu, 28 Jul 2016 13:44:25 -0400 Received: from swarren-lx1.nvidia.com (thunderhill.nvidia.com [216.228.112.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by avon.wwwdotorg.org (Postfix) with ESMTPSA id 8ACA71C02BF; Thu, 28 Jul 2016 11:44:26 -0600 (MDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.99 at avon.wwwdotorg.org From: Stephen Warren To: swarren@wwwdotorg.org Cc: linux-tegra@vger.kernel.org, Stephen Warren , Jimmy Zhang Subject: [cbootimage PATCH] bct_dump: don't crash on devices without RSA support Date: Thu, 28 Jul 2016 11:44:05 -0600 Message-Id: <20160728174405.16136-1-swarren@wwwdotorg.org> X-Mailer: git-send-email 2.9.2 X-NVConfidentiality: public Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org From: Stephen Warren 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 Signed-off-by: Stephen Warren --- src/bct_dump.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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++);