From: Jan Glauber Date: Wed, 17 Mar 2021 14:04:39 +0000 (+0100) Subject: md: Fix missing unused status line of /proc/mdstat X-Git-Tag: v5.11.21~547 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6dc517ed273c003a1c5b760d98625ecf59f91118;p=thirdparty%2Fkernel%2Fstable.git md: Fix missing unused status line of /proc/mdstat commit 7abfabaf5f805f5171d133ce6af9b65ab766e76a upstream. Reading /proc/mdstat with a read buffer size that would not fit the unused status line in the first read will skip this line from the output. So 'dd if=/proc/mdstat bs=64 2>/dev/null' will not print something like: unused devices: Don't return NULL immediately in start() for v=2 but call show() once to print the status line also for multiple reads. Cc: stable@vger.kernel.org Fixes: 1f4aace60b0e ("fs/seq_file.c: simplify seq_file iteration code and interface") Signed-off-by: Jan Glauber Signed-off-by: Song Liu Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/md/md.c b/drivers/md/md.c index 5205d7ca055cd..b15a96708a6d2 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -8187,7 +8187,11 @@ static void *md_seq_start(struct seq_file *seq, loff_t *pos) loff_t l = *pos; struct mddev *mddev; - if (l >= 0x10000) + if (l == 0x10000) { + ++*pos; + return (void *)2; + } + if (l > 0x10000) return NULL; if (!l--) /* header */