Skip to content

Commit 2ca48a1

Browse files
James BottomleyJames Bottomley
authored andcommitted
[SCSI] fix proc_scsi_write to return "length" on success with remove-single-device case
Problem spotted by: Suzuki K P <suzuki@in.ibm.com> A zero return on success isn't correct for filesystem write functions. They should either return negative error or the length of bytes consumed. Add code to convert our zero on success error return to return the length of bytes passed in. This fixes the following: $ echo "scsi remove-single-device 0 0 3 0" > /proc/scsi/scsi bash: echo: write error: No such device or address" Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
1 parent 665b44a commit 2ca48a1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/scsi/scsi_proc.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,6 @@ static ssize_t proc_scsi_write(struct file *file, const char __user *buf,
266266
lun = simple_strtoul(p + 1, &p, 0);
267267

268268
err = scsi_add_single_device(host, channel, id, lun);
269-
if (err >= 0)
270-
err = length;
271269

272270
/*
273271
* Usage: echo "scsi remove-single-device 0 1 2 3" >/proc/scsi/scsi
@@ -284,6 +282,13 @@ static ssize_t proc_scsi_write(struct file *file, const char __user *buf,
284282
err = scsi_remove_single_device(host, channel, id, lun);
285283
}
286284

285+
/*
286+
* convert success returns so that we return the
287+
* number of bytes consumed.
288+
*/
289+
if (!err)
290+
err = length;
291+
287292
out:
288293
free_page((unsigned long)buffer);
289294
return err;

0 commit comments

Comments
 (0)