Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2652915pxb; Tue, 24 Aug 2021 04:33:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxECYAZLprui1sdN7n5D5A4oc75qM8/h6NH9SASgt0JibUUHiOxLtkzg6jk0oBLQVYpIxbj X-Received: by 2002:a17:906:b0c8:: with SMTP id bk8mr40717907ejb.412.1629804798399; Tue, 24 Aug 2021 04:33:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629804798; cv=none; d=google.com; s=arc-20160816; b=IxR9xx4TpaxE6LshKIypm4WamkR4G+08qwy1g/lCeVgw3qZTpj3qZ07T4kYTqmJGHd zzeEHwUVI1cuJcB2HcPTLg/CCmOcGtXSU5M+SDRO87tKyF2XqXU1c6wXl6i+/omf+K+X XI0aMpP6ZMYyoYwc0GEFY/6huQ6ivz9J1TUnUngbdnCxv94YHbgTyWS89FdBP8zXFfBX YbMpDnsUH6TC4WZHCHVKJkHLqtfl6y3oXPoJFdFtjb17+xJkG6HVXTMUcrCAgEsGUwiI uRHLIIeFwRPBNXeogvwXnGvCdvWhBwxzKPa8OHiptKuDNHZwnDzru33XyWg22v7KIbCb 2VYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=FreLuXtpPO5M0wpQU/au7ZiAqtijlcsGc59gKKgk/cE=; b=jf1Kob95rfUhJrWyVrz6G3HffKS1GN4tM6O5W4rpLiGXrO5IMvc/iI/Iopj9yT5Nwf c6G7CBjtMYeGO/m8cHuY5or57Qj4tE1cor43YzhVkvKUfPjitFSs4XmiKHS3rSjUnDfW GXeNqh8o2PTsLqqi/JEz8HX1/NxVasq3qMtz7bjsntcJ0UcXDVDmU5uDcZ1jiIdXafbC fwK6ibKKrxvpTuSKGUZnGP4lGCjiFJieCBH1ThaYi4PURxBsmXrpJqgpO7FojPARII16 KiBhqAm8blNOXlIvOAdrRtjg9kqbC9WX15rHAW8WVQxdW6Q3NKQYsm3GPSEkwuPhbq2N Gpmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CSa5G9X9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y16si10435981edd.310.2021.08.24.04.32.55; Tue, 24 Aug 2021 04:33:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CSa5G9X9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237030AbhHXLbS (ORCPT + 99 others); Tue, 24 Aug 2021 07:31:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236795AbhHXLay (ORCPT ); Tue, 24 Aug 2021 07:30:54 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FE2DC061796 for ; Tue, 24 Aug 2021 04:30:10 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id l18so29492031lji.12 for ; Tue, 24 Aug 2021 04:30:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FreLuXtpPO5M0wpQU/au7ZiAqtijlcsGc59gKKgk/cE=; b=CSa5G9X9T10H39Cf/4WsJMIxldeEYSZf5kx/O07w10fZxVPEumBmJD1Kf2LVpJKp+g 8iS5NXOGRh+fdG+c2yAcHS6cf2m6CK/Am3BaWXW/hjiMg6RW/DTv4Qb9ykuxIwhE4mSO tYrJumdu2IGkMZwbAFIdJCTZhunSMPu/qf9L5JBmLd3rEAomkKZ2ysTC/ESmnWk+uoLH dhTdigaeNI3a7Ibl2b/f+kWgNubmfACJ6CgL5aC4vWMEvCJQZnMQpI2GgQ5Ggf5PYrLD B/T4J+orYR8TXEg7Gl9rtKcV/bhxs/Qfzg1ja7iPm4UNCSG/8xr5MSxG++9UDXW47kET aUuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FreLuXtpPO5M0wpQU/au7ZiAqtijlcsGc59gKKgk/cE=; b=RPUZwA6qUemD77wIS7uhZm0OYvRIhjHWErcPly+sNH6BdKhb2wo6ihAVtXBibQHds/ w3sYUMU5MVlbF8Etl9gGml30db4OJB2CxCH/H0K1w8Ob5oXzo9/1VoIqZquMR0T3gKgB q8ip8f+nMPflBj9+Ocg93HroaKMsb/2VR5telygtO/eTYlUp/ZSPvDxEvjQM+CEpK/ai tu14V+esgc/mhXkGLaHI7urnQTQY8yDwiTPTUD6+B8hzCj6xqw4dFgaZQiSM0G4svP3K wb9gRAh17+JgDJ9NNkDPxON7igrfrNLmyIwZnExh4Co9RI38ASMlWNnHhljpepYJ2Gum i2Lw== X-Gm-Message-State: AOAM531Cyv+Kvu7xBTSZH768qdJbAnj/1MTI/eVq0WURtINGI8qhbi3N aIIRAn895YjDxl4uR1tDkrazyocELY1iIROLKR7Jaw== X-Received: by 2002:a05:651c:83:: with SMTP id 3mr31894238ljq.341.1629804608413; Tue, 24 Aug 2021 04:30:08 -0700 (PDT) MIME-Version: 1.0 References: <20210713053458.1441-1-oracleks043021@gmail.com> In-Reply-To: From: Ulf Hansson Date: Tue, 24 Aug 2021 13:29:32 +0200 Message-ID: Subject: Re: [PATCH v1] mmc-utils: Fix for Firmware Version string printing To: Avri Altman , "oracleks043021@gmail.com" Cc: "beanhuo@micron.com" , "kenny.gibbons@oracle.com" , "kimito.sakata@oracle.com" , "rkamdar@micron.com" , "chris@printf.net" , "linux-mmc@vger.kernel.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 13 Jul 2021 at 10:00, Avri Altman wrote: > > > > > From: Kimito Sakata > > > > Added a local buffer to create a NULL terminated string to print the > > Firmware Version instead of attempting to print directly from > > ext_csd buffer. The last byte of the Firmware Version field may not > > be NULL and the next field may also not be which may cause it to > > print garbage. > > > > Tested on x86 platform. > Fixes: 89cd01ed865a (mmc_utils: add ffu support) > > Signed-off-by: Kimito Sakata > Reviewed-by: Avri Altman Applied for master at git.kernel.org/pub/scm/utils/mmc/mmc-utils.git, thanks! Kind regards Uffe > > > --- > > mmc_cmds.c | 6 ++++-- > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > diff --git a/mmc_cmds.c b/mmc_cmds.c > > index afa85b7..205e6e5 100644 > > --- a/mmc_cmds.c > > +++ b/mmc_cmds.c > > @@ -1392,6 +1392,7 @@ int do_read_extcsd(int nargs, char **argv) > > __u32 regl; > > int fd, ret; > > char *device; > > + char lbuf[10]; > > const char *str; > > > > if (nargs != 2) { > > @@ -1833,8 +1834,9 @@ int do_read_extcsd(int nargs, char **argv) > > } > > > > if (ext_csd_rev >= 7) { > > - printf("eMMC Firmware Version: %s\n", > > - (char*)&ext_csd[EXT_CSD_FIRMWARE_VERSION]); > > + memset(lbuf, 0, sizeof(lbuf)); > > + strncpy(lbuf, (char*)&ext_csd[EXT_CSD_FIRMWARE_VERSION], 8); > > + printf("eMMC Firmware Version: %s\n", lbuf); > > printf("eMMC Life Time Estimation A > > [EXT_CSD_DEVICE_LIFE_TIME_EST_TYP_A]: 0x%02x\n", > > ext_csd[EXT_CSD_DEVICE_LIFE_TIME_EST_TYP_A]); > > printf("eMMC Life Time Estimation B > > [EXT_CSD_DEVICE_LIFE_TIME_EST_TYP_B]: 0x%02x\n", > > -- > > 2.31.1 >