linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: willy@linux.intel.com (Matthew Wilcox)
Subject: [PATCH] NVMe:Expose model attribute in sysfs
Date: Tue, 25 Aug 2015 11:38:54 -0400	[thread overview]
Message-ID: <20150825153854.GA2862@linux.intel.com> (raw)
In-Reply-To: <20150825045412.GA20360@localhost.localdomain>

On Tue, Aug 25, 2015@10:24:39AM +0530, Sujith Pandel wrote:
> @@ -2360,6 +2360,7 @@ static int nvme_dev_add(struct nvme_dev *dev)
>  	dev->vwc = ctrl->vwc;
>  	memcpy(dev->serial, ctrl->sn, sizeof(ctrl->sn));
>  	memcpy(dev->model, ctrl->mn, sizeof(ctrl->mn));
> +	dev->model[sizeof(ctrl->mn) - 1] = '\0';
>  	memcpy(dev->firmware_rev, ctrl->fr, sizeof(ctrl->fr));
>  	if (ctrl->mdts)
>  		dev->max_hw_sectors = 1 << (ctrl->mdts + shift - 9);

You've overwritten the last byte of the model name with a NUL byte.  There
could be useful information in that byte.

> +/* Expose model name in sysfs */
> +static ssize_t nvme_sysfs_model(struct device *dev,
> +				struct device_attribute *attr, char *buf)
> +{
> +	struct nvme_dev *ndev = dev_get_drvdata(dev);
> +
> +	return sprintf(buf, "%s\n", ndev->model);

Instead, how about:

	return sprintf(buf, "%.40s\n", ndev->model);

  reply	other threads:[~2015-08-25 15:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-25  4:54 [PATCH] NVMe:Expose model attribute in sysfs Sujith Pandel
2015-08-25 15:38 ` Matthew Wilcox [this message]
2015-09-01 16:38   ` Sujith Pandel
2015-08-25 17:14 ` Keith Busch
2015-09-01 16:55   ` Sujith Pandel
2015-09-01 17:25     ` Keith Busch
2015-09-04  4:54       ` Sujith Pandel
2015-09-08 21:29         ` Keith Busch
2015-09-09  4:46           ` Sujith Pandel

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=20150825153854.GA2862@linux.intel.com \
    --to=willy@linux.intel.com \
    /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).