* [patch] target: handle empty string writes in sysfs
@ 2012-01-24 8:40 Dan Carpenter
2012-01-24 10:55 ` walter harms
0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2012-01-24 8:40 UTC (permalink / raw)
To: Nicholas A. Bellinger; +Cc: linux-scsi, target-devel, kernel-janitors
These are root only and we're not likely to hit the problem in practise,
but it makes a the static checkers happy.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index 0955bb8..9b86330 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -1707,6 +1707,8 @@ static ssize_t target_core_store_dev_alias(
se_dev->su_dev_flags |= SDF_USING_ALIAS;
read_bytes = snprintf(&se_dev->se_dev_alias[0], SE_DEV_ALIAS_LEN,
"%s", page);
+ if (read_bytes == 0)
+ return -EINVAL;
if (se_dev->se_dev_alias[read_bytes - 1] == '\n')
se_dev->se_dev_alias[read_bytes - 1] = '\0';
@@ -1756,6 +1758,8 @@ static ssize_t target_core_store_dev_udev_path(
se_dev->su_dev_flags |= SDF_USING_UDEV_PATH;
read_bytes = snprintf(&se_dev->se_dev_udev_path[0], SE_UDEV_PATH_LEN,
"%s", page);
+ if (read_bytes == 0)
+ return -EINVAL;
if (se_dev->se_dev_udev_path[read_bytes - 1] == '\n')
se_dev->se_dev_udev_path[read_bytes - 1] = '\0';
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [patch] target: handle empty string writes in sysfs
2012-01-24 8:40 [patch] target: handle empty string writes in sysfs Dan Carpenter
@ 2012-01-24 10:55 ` walter harms
2012-01-26 12:19 ` Dan Carpenter
2012-01-27 12:50 ` [patch v2] " Dan Carpenter
0 siblings, 2 replies; 4+ messages in thread
From: walter harms @ 2012-01-24 10:55 UTC (permalink / raw)
To: Dan Carpenter
Cc: Nicholas A. Bellinger, linux-scsi, target-devel, kernel-janitors
Am 24.01.2012 09:40, schrieb Dan Carpenter:
> These are root only and we're not likely to hit the problem in practise,
> but it makes a the static checkers happy.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
> index 0955bb8..9b86330 100644
> --- a/drivers/target/target_core_configfs.c
> +++ b/drivers/target/target_core_configfs.c
> @@ -1707,6 +1707,8 @@ static ssize_t target_core_store_dev_alias(
> se_dev->su_dev_flags |= SDF_USING_ALIAS;
> read_bytes = snprintf(&se_dev->se_dev_alias[0], SE_DEV_ALIAS_LEN,
> "%s", page);
Would it help to check page==NULL or *page==0 at start ?
Now you have se_dev->su_dev_flags initialised.
re,
wh
> + if (read_bytes == 0)
> + return -EINVAL;
>
> if (se_dev->se_dev_alias[read_bytes - 1] == '\n')
> se_dev->se_dev_alias[read_bytes - 1] = '\0';
> @@ -1756,6 +1758,8 @@ static ssize_t target_core_store_dev_udev_path(
> se_dev->su_dev_flags |= SDF_USING_UDEV_PATH;
> read_bytes = snprintf(&se_dev->se_dev_udev_path[0], SE_UDEV_PATH_LEN,
> "%s", page);
> + if (read_bytes == 0)
> + return -EINVAL;
>
> if (se_dev->se_dev_udev_path[read_bytes - 1] == '\n')
> se_dev->se_dev_udev_path[read_bytes - 1] = '\0';
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] target: handle empty string writes in sysfs
2012-01-24 10:55 ` walter harms
@ 2012-01-26 12:19 ` Dan Carpenter
2012-01-27 12:50 ` [patch v2] " Dan Carpenter
1 sibling, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2012-01-26 12:19 UTC (permalink / raw)
To: walter harms
Cc: Nicholas A. Bellinger, linux-scsi, target-devel, kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 941 bytes --]
On Tue, Jan 24, 2012 at 11:55:45AM +0100, walter harms wrote:
>
>
> Am 24.01.2012 09:40, schrieb Dan Carpenter:
> > These are root only and we're not likely to hit the problem in practise,
> > but it makes a the static checkers happy.
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >
> > diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
> > index 0955bb8..9b86330 100644
> > --- a/drivers/target/target_core_configfs.c
> > +++ b/drivers/target/target_core_configfs.c
> > @@ -1707,6 +1707,8 @@ static ssize_t target_core_store_dev_alias(
> > se_dev->su_dev_flags |= SDF_USING_ALIAS;
> > read_bytes = snprintf(&se_dev->se_dev_alias[0], SE_DEV_ALIAS_LEN,
> > "%s", page);
>
> Would it help to check page==NULL or *page==0 at start ?
> Now you have se_dev->su_dev_flags initialised.
It's a fair point. Let me redo it.
regards,
dan carpenter
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* [patch v2] target: handle empty string writes in sysfs
2012-01-24 10:55 ` walter harms
2012-01-26 12:19 ` Dan Carpenter
@ 2012-01-27 12:50 ` Dan Carpenter
1 sibling, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2012-01-27 12:50 UTC (permalink / raw)
To: walter harms
Cc: Nicholas A. Bellinger, linux-scsi, target-devel, kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 1627 bytes --]
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: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: only set ->su_dev_flags on success.
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index 0955bb8..6e043ee 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -1704,13 +1704,15 @@ static ssize_t target_core_store_dev_alias(
return -EINVAL;
}
- se_dev->su_dev_flags |= SDF_USING_ALIAS;
read_bytes = snprintf(&se_dev->se_dev_alias[0], SE_DEV_ALIAS_LEN,
"%s", page);
-
+ if (!read_bytes)
+ return -EINVAL;
if (se_dev->se_dev_alias[read_bytes - 1] == '\n')
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",
config_item_name(&hba->hba_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(
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,
"%s", page);
-
+ if (!read_bytes)
+ return -EINVAL;
if (se_dev->se_dev_udev_path[read_bytes - 1] == '\n')
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",
config_item_name(&hba->hba_group.cg_item),
config_item_name(&se_dev->se_dev_group.cg_item),
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-01-27 12:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-24 8:40 [patch] target: handle empty string writes in sysfs Dan Carpenter
2012-01-24 10:55 ` walter harms
2012-01-26 12:19 ` Dan Carpenter
2012-01-27 12:50 ` [patch v2] " Dan Carpenter
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).