summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorTomohiro Kusumi <[email protected]>2019-06-21 10:31:53 +0900
committerBrian Behlendorf <[email protected]>2019-06-20 18:31:52 -0700
commit9585497208266a917513754f887d9db35efdcec7 (patch)
tree8f6c5797f5b407d804bd2c22efe601e799e10bb4 /module
parentaccd6d9dc411b150d5313b2e777381f13da8861b (diff)
Prevent pointer to an out-of-scope local variable
`show_str` could be a pointer to a local variable in stack which is out-of-scope by the time `return (snprintf(buf, buflen, "%s\n", show_str));` is called. Reviewed-by: Tony Hutter <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Tomohiro Kusumi <[email protected]> Closes #8924 Closes #8940
Diffstat (limited to 'module')
-rw-r--r--module/zfs/zfs_sysfs.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/module/zfs/zfs_sysfs.c b/module/zfs/zfs_sysfs.c
index 2f5bea9aa..bb7f3b69a 100644
--- a/module/zfs/zfs_sysfs.c
+++ b/module/zfs/zfs_sysfs.c
@@ -264,6 +264,7 @@ zprop_sysfs_show(const char *attr_name, const zprop_desc_t *property,
char *buf, size_t buflen)
{
const char *show_str;
+ char number[32];
/* For dataset properties list the dataset types that apply */
if (strcmp(attr_name, "datasets") == 0 &&
@@ -291,8 +292,6 @@ zprop_sysfs_show(const char *attr_name, const zprop_desc_t *property,
} else if (strcmp(attr_name, "values") == 0) {
show_str = property->pd_values ? property->pd_values : "";
} else if (strcmp(attr_name, "default") == 0) {
- char number[32];
-
switch (property->pd_proptype) {
case PROP_TYPE_NUMBER:
(void) snprintf(number, sizeof (number), "%llu",