Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1232411
| From | Toshi Kani <toshi.kani@hpe.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v2 2/2] EDAC: Fix sysfs dimm_label store operation |
| Date | 2015-09-24 22:10 +0200 |
| Message-ID | <qcl06-4Uy-17@gated-at.bofh.it> (permalink) |
| References | <qbxmF-sc-9@gated-at.bofh.it> <qbxmF-sc-7@gated-at.bofh.it> <qchSz-gB-19@gated-at.bofh.it> <qck42-3yV-41@gated-at.bofh.it> <qckdJ-3Kz-31@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Thu, 2015-09-24 at 21:15 +0200, Borislav Petkov wrote: > On Thu, Sep 24, 2015 at 01:06:04PM -0600, Toshi Kani wrote: > > edac-utils(1) checks empty labels and shows them as "ch%d" [1]. So, > > I think empty labels are supported today, and using 'echo "" >' seems > > to be a legitimate way to set them empty if desired. > > What would be a sane use case to set a DIMM label to an empty string? Well, I guess there isn't a sane use case for it... :-) Attached is a patch (on top of patch 2/2) to disallow an empty string. I prefer to make it as a separate patch in case someone comes up with a valid use-case for it. Thanks, -Toshi ==== Subject: [PATCH] EDAC: Fail empty string to sysfs dimm_label store Updating dimm_label to an empty string does not make much sense. Change the sysfs dimm_label store option to fail a request when an input string is empty. Suggested-by: Borislav Petkov <bp@alien8.de> Signed-off-by: Toshi Kani <toshi.kani@hpe.com> --- drivers/edac/edac_mc_sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c index 5252fb9..72ba530 100644 --- a/drivers/edac/edac_mc_sysfs.c +++ b/drivers/edac/edac_mc_sysfs.c @@ -248,7 +248,7 @@ static ssize_t channel_dimm_label_store(struct device *dev, if (data[count - 1] == '\0' || data[count - 1] == '\n') copy_count -= 1; - if (copy_count >= sizeof(rank->dimm->label)) + if (copy_count == 0 || copy_count >= sizeof(rank->dimm->label)) return -EINVAL; strncpy(rank->dimm->label, data, copy_count); @@ -509,7 +509,7 @@ static ssize_t dimmdev_label_store(struct device *dev, if (data[count - 1] == '\0' || data[count - 1] == '\n') copy_count -= 1; - if (copy_count >= sizeof(dimm->label)) + if (copy_count == 0 || copy_count >= sizeof(dimm->label)) return -EINVAL; strncpy(dimm->label, data, copy_count); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 2/2] EDAC: Fix sysfs dimm_label store operation Toshi Kani <toshi.kani@hpe.com> - 2015-09-22 17:10 +0200
Re: [PATCH v2 2/2] EDAC: Fix sysfs dimm_label store operation Borislav Petkov <bp@alien8.de> - 2015-09-24 18:50 +0200
Re: [PATCH v2 2/2] EDAC: Fix sysfs dimm_label store operation Toshi Kani <toshi.kani@hpe.com> - 2015-09-24 21:10 +0200
Re: [PATCH v2 2/2] EDAC: Fix sysfs dimm_label store operation Borislav Petkov <bp@alien8.de> - 2015-09-24 21:20 +0200
Re: [PATCH v2 2/2] EDAC: Fix sysfs dimm_label store operation Toshi Kani <toshi.kani@hpe.com> - 2015-09-24 22:10 +0200
Re: [PATCH v2 2/2] EDAC: Fix sysfs dimm_label store operation Borislav Petkov <bp@alien8.de> - 2015-09-25 20:00 +0200
csiph-web