From: Toshi Kani <toshi.kani@hpe.com>
To: mchehab@osg.samsung.com, bp@alien8.de, dougthompson@xmission.com
Cc: linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org,
elliott@hpe.com, tony.luck@intel.com
Subject: Re: [PATCH 2/2] EDAC: Fix sysfs dimm_label store operation
Date: Mon, 21 Sep 2015 17:40:35 -0600 [thread overview]
Message-ID: <1442878835.25474.119.camel@hpe.com> (raw)
In-Reply-To: <1442863184-17935-3-git-send-email-toshi.kani@hpe.com>
On Mon, 2015-09-21 at 13:19 -0600, Toshi Kani wrote:
:
>
> diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
> index 8983755..f2ea914 100644
> --- a/drivers/edac/edac_mc_sysfs.c
> +++ b/drivers/edac/edac_mc_sysfs.c
> @@ -241,13 +241,14 @@ static ssize_t channel_dimm_label_store(struct
> device *dev,
> unsigned chan = to_channel(mattr);
> struct rank_info *rank = csrow->channels[chan];
>
> - ssize_t max_size = 0;
> + if (count == 0 || count > sizeof(rank->dimm->label))
> + return -EINVAL;
>
> - max_size = min((ssize_t) count, (ssize_t) EDAC_MC_LABEL_LEN - 1);
> - strncpy(rank->dimm->label, data, max_size);
> - rank->dimm->label[max_size] = '\0';
> + strncpy(rank->dimm->label, data, count);
> + if (rank->dimm->label[count - 1] == '\n')
> + rank->dimm->label[count - 1] = '\0';
Thinking further, it'd be safer to always set a null at the end. I will
update the patch.
-Toshi
next prev parent reply other threads:[~2015-09-21 23:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-21 19:19 [PATCH 0/2] EDAC: Fix sysfs dimm_label show & store operations Toshi Kani
2015-09-21 19:19 ` [PATCH 1/2] EDAC: Fix sysfs dimm_label show operation Toshi Kani
2015-09-21 19:19 ` [PATCH 2/2] EDAC: Fix sysfs dimm_label store operation Toshi Kani
2015-09-21 23:40 ` Toshi Kani [this message]
2015-09-21 21:20 ` [PATCH 0/2] EDAC: Fix sysfs dimm_label show & store operations Luck, Tony
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=1442878835.25474.119.camel@hpe.com \
--to=toshi.kani@hpe.com \
--cc=bp@alien8.de \
--cc=dougthompson@xmission.com \
--cc=elliott@hpe.com \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab@osg.samsung.com \
--cc=tony.luck@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