提交 3011684c 编写于 作者: D Dan Carpenter 提交者: Nicholas Bellinger

target: handle empty string writes in sysfs

These are root only and we're not likely to hit the problem in practise,
but it makes the static checkers happy.
Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
上级 c3bc93da
...@@ -1704,13 +1704,15 @@ static ssize_t target_core_store_dev_alias( ...@@ -1704,13 +1704,15 @@ static ssize_t target_core_store_dev_alias(
return -EINVAL; return -EINVAL;
} }
se_dev->su_dev_flags |= SDF_USING_ALIAS;
read_bytes = snprintf(&se_dev->se_dev_alias[0], SE_DEV_ALIAS_LEN, read_bytes = snprintf(&se_dev->se_dev_alias[0], SE_DEV_ALIAS_LEN,
"%s", page); "%s", page);
if (!read_bytes)
return -EINVAL;
if (se_dev->se_dev_alias[read_bytes - 1] == '\n') if (se_dev->se_dev_alias[read_bytes - 1] == '\n')
se_dev->se_dev_alias[read_bytes - 1] = '\0'; se_dev->se_dev_alias[read_bytes - 1] = '\0';
se_dev->su_dev_flags |= SDF_USING_ALIAS;
pr_debug("Target_Core_ConfigFS: %s/%s set alias: %s\n", pr_debug("Target_Core_ConfigFS: %s/%s set alias: %s\n",
config_item_name(&hba->hba_group.cg_item), config_item_name(&hba->hba_group.cg_item),
config_item_name(&se_dev->se_dev_group.cg_item), config_item_name(&se_dev->se_dev_group.cg_item),
...@@ -1753,13 +1755,15 @@ static ssize_t target_core_store_dev_udev_path( ...@@ -1753,13 +1755,15 @@ static ssize_t target_core_store_dev_udev_path(
return -EINVAL; return -EINVAL;
} }
se_dev->su_dev_flags |= SDF_USING_UDEV_PATH;
read_bytes = snprintf(&se_dev->se_dev_udev_path[0], SE_UDEV_PATH_LEN, read_bytes = snprintf(&se_dev->se_dev_udev_path[0], SE_UDEV_PATH_LEN,
"%s", page); "%s", page);
if (!read_bytes)
return -EINVAL;
if (se_dev->se_dev_udev_path[read_bytes - 1] == '\n') if (se_dev->se_dev_udev_path[read_bytes - 1] == '\n')
se_dev->se_dev_udev_path[read_bytes - 1] = '\0'; se_dev->se_dev_udev_path[read_bytes - 1] = '\0';
se_dev->su_dev_flags |= SDF_USING_UDEV_PATH;
pr_debug("Target_Core_ConfigFS: %s/%s set udev_path: %s\n", pr_debug("Target_Core_ConfigFS: %s/%s set udev_path: %s\n",
config_item_name(&hba->hba_group.cg_item), config_item_name(&hba->hba_group.cg_item),
config_item_name(&se_dev->se_dev_group.cg_item), config_item_name(&se_dev->se_dev_group.cg_item),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册