linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Avri Altman <Avri.Altman@wdc.com>
To: "oracleks043021@gmail.com" <oracleks043021@gmail.com>,
	"beanhuo@micron.com" <beanhuo@micron.com>,
	"kenny.gibbons@oracle.com" <kenny.gibbons@oracle.com>,
	"kimito.sakata@oracle.com" <kimito.sakata@oracle.com>,
	"rkamdar@micron.com" <rkamdar@micron.com>,
	"chris@printf.net" <chris@printf.net>,
	"ulf.hansson@linaro.org" <ulf.hansson@linaro.org>
Cc: "linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v1] mmc-utils: Fix for Firmware Version string printing
Date: Tue, 13 Jul 2021 08:00:23 +0000	[thread overview]
Message-ID: <DM6PR04MB65754DC90E423A79D80263C1FC149@DM6PR04MB6575.namprd04.prod.outlook.com> (raw)
In-Reply-To: <20210713053458.1441-1-oracleks043021@gmail.com>

> 
> From: Kimito Sakata <kimito.sakata@oracle.com>
> 
> 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 <kimito.sakata@oracle.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>

> ---
>  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


  reply	other threads:[~2021-07-13  8:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-13  5:34 [PATCH v1] mmc-utils: Fix for Firmware Version string printing oracleks043021
2021-07-13  8:00 ` Avri Altman [this message]
2021-08-24 11:29   ` Ulf Hansson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DM6PR04MB65754DC90E423A79D80263C1FC149@DM6PR04MB6575.namprd04.prod.outlook.com \
    --to=avri.altman@wdc.com \
    --cc=beanhuo@micron.com \
    --cc=chris@printf.net \
    --cc=kenny.gibbons@oracle.com \
    --cc=kimito.sakata@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=oracleks043021@gmail.com \
    --cc=rkamdar@micron.com \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).