parisc: Fix return code of pdc_iodc_print()
authorHelge Deller <deller@gmx.de>
Mon, 19 Dec 2022 19:56:36 +0000 (20:56 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Feb 2023 10:26:43 +0000 (11:26 +0100)
commit 5d1335dabb3c493a3d6d5b233953b6ac7b6c1ff2 upstream.

There is an off-by-one if the printed string includes a new-line
char.

Cc: stable@vger.kernel.org
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/parisc/kernel/firmware.c

index 7034227dbdf32a83e37cc1ea8af6cfe3ef718265..8e5a906df9175e42a1f3ab946031536f39ac3d6d 100644 (file)
@@ -1230,7 +1230,7 @@ static char __attribute__((aligned(64))) iodc_dbuf[4096];
  */
 int pdc_iodc_print(const unsigned char *str, unsigned count)
 {
-       unsigned int i;
+       unsigned int i, found = 0;
        unsigned long flags;
 
        for (i = 0; i < count;) {
@@ -1239,6 +1239,7 @@ int pdc_iodc_print(const unsigned char *str, unsigned count)
                        iodc_dbuf[i+0] = '\r';
                        iodc_dbuf[i+1] = '\n';
                        i += 2;
+                       found = 1;
                        goto print;
                default:
                        iodc_dbuf[i] = str[i];
@@ -1255,7 +1256,7 @@ print:
                     __pa(iodc_retbuf), 0, __pa(iodc_dbuf), i, 0);
         spin_unlock_irqrestore(&pdc_lock, flags);
 
-       return i;
+       return i - found;
 }
 
 #if !defined(BOOTLOADER)