* [PATCH] scsi: scsi_devinfo: return an error when the proc write fails
@ 2026-10-31 14:21 shao.mingyin
2026-10-31 19:31 ` Laurence Oberman
0 siblings, 1 reply; 2+ messages in thread
From: shao.mingyin @ 2026-10-31 14:21 UTC (permalink / raw)
To: mkp, james.bottomley, linux-scsi; +Cc: linux-kernel
From: Shao Mingyin <shao.mingyin@zte.com.cn>
proc_scsi_devinfo_write() calls scsi_dev_info_list_add_str() but ignores
its return value, so a write to /proc/scsi/device_info always reports
success, even when the string is malformed and no entry was added. Users
and scripts then believe that the quirk is in effect.
scsi_init_devinfo() already checks the return value of the same function
and fails the initialization. Return the parser error, but keep returning
the number of bytes written on success: a proc write handler that returns
zero for a non-empty write would look like a short write to the caller.
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
---
diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
index cfc259fd0141..b1f3bcd739b4 100644
--- a/drivers/scsi/scsi_devinfo.c
+++ b/drivers/scsi/scsi_devinfo.c
@@ -688,6 +688,7 @@ static ssize_t proc_scsi_devinfo_write(struct file *file,
{
char *buffer;
ssize_t err = length;
+ int ret;
if (!buf || length>PAGE_SIZE)
return -EINVAL;
@@ -706,7 +707,9 @@ static ssize_t proc_scsi_devinfo_write(struct file *file,
goto out;
}
- scsi_dev_info_list_add_str(buffer);
+ ret = scsi_dev_info_list_add_str(buffer);
+ if (ret)
+ err = ret;
out:
kfree(buffer);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] scsi: scsi_devinfo: return an error when the proc write fails
2026-10-31 14:21 [PATCH] scsi: scsi_devinfo: return an error when the proc write fails shao.mingyin
@ 2026-10-31 19:31 ` Laurence Oberman
0 siblings, 0 replies; 2+ messages in thread
From: Laurence Oberman @ 2026-10-31 19:31 UTC (permalink / raw)
To: shao.mingyin, mkp, james.bottomley, linux-scsi; +Cc: linux-kernel
On Sat, 2026-10-31 at 22:21 +0800, shao.mingyin@zte.com.cn wrote:
> From: Shao Mingyin <shao.mingyin@zte.com.cn>
>
> proc_scsi_devinfo_write() calls scsi_dev_info_list_add_str() but
> ignores
> its return value, so a write to /proc/scsi/device_info always reports
> success, even when the string is malformed and no entry was added.
> Users
> and scripts then believe that the quirk is in effect.
>
> scsi_init_devinfo() already checks the return value of the same
> function
> and fails the initialization. Return the parser error, but keep
> returning
> the number of bytes written on success: a proc write handler that
> returns
> zero for a non-empty write would look like a short write to the
> caller.
>
> Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
> ---
> diff --git a/drivers/scsi/scsi_devinfo.c
> b/drivers/scsi/scsi_devinfo.c
> index cfc259fd0141..b1f3bcd739b4 100644
> --- a/drivers/scsi/scsi_devinfo.c
> +++ b/drivers/scsi/scsi_devinfo.c
> @@ -688,6 +688,7 @@ static ssize_t proc_scsi_devinfo_write(struct
> file *file,
> {
> char *buffer;
> ssize_t err = length;
> + int ret;
>
> if (!buf || length>PAGE_SIZE)
> return -EINVAL;
> @@ -706,7 +707,9 @@ static ssize_t proc_scsi_devinfo_write(struct
> file *file,
> goto out;
> }
>
> - scsi_dev_info_list_add_str(buffer);
> + ret = scsi_dev_info_list_add_str(buffer);
> + if (ret)
> + err = ret;
>
> out:
> kfree(buffer);
Looks good to me.
Note that a multi-entry write can still partially apply (entries before
the bad one are added, then -EINVAL is returned), but reporting the
error is a clear improvement over silent success.
Reviewed-by: Laurence Oberman <loberman@redhat.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-31 19:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-31 14:21 [PATCH] scsi: scsi_devinfo: return an error when the proc write fails shao.mingyin
2026-10-31 19:31 ` Laurence Oberman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®