Patch "auxdisplay: img-ascii-lcd: Fix lock-up when displaying empty string" has been added to the 4.14-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    auxdisplay: img-ascii-lcd: Fix lock-up when displaying empty string

to the 4.14-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     auxdisplay-img-ascii-lcd-fix-lock-up-when-displaying.patch
and it can be found in the queue-4.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 694de5c193c1398b7713cd46fec180350ae592da
Author: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
Date:   Tue Oct 19 16:45:02 2021 +0200

    auxdisplay: img-ascii-lcd: Fix lock-up when displaying empty string
    
    [ Upstream commit afcb5a811ff3ab3969f09666535eb6018a160358 ]
    
    While writing an empty string to a device attribute is a no-op, and thus
    does not need explicit safeguards, the user can still write a single
    newline to an attribute file:
    
        echo > .../message
    
    If that happens, img_ascii_lcd_display() trims the newline, yielding an
    empty string, and causing an infinite loop in img_ascii_lcd_scroll().
    
    Fix this by adding a check for empty strings.  Clear the display in case
    one is encountered.
    
    Fixes: 0cad855fbd083ee5 ("auxdisplay: img-ascii-lcd: driver for simple ASCII LCD displays")
    Signed-off-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
    Signed-off-by: Miguel Ojeda <ojeda@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/auxdisplay/img-ascii-lcd.c b/drivers/auxdisplay/img-ascii-lcd.c
index 58403052514f0..4d57185037a0d 100644
--- a/drivers/auxdisplay/img-ascii-lcd.c
+++ b/drivers/auxdisplay/img-ascii-lcd.c
@@ -284,6 +284,16 @@ static int img_ascii_lcd_display(struct img_ascii_lcd_ctx *ctx,
 	if (msg[count - 1] == '\n')
 		count--;
 
+	if (!count) {
+		/* clear the LCD */
+		devm_kfree(&ctx->pdev->dev, ctx->message);
+		ctx->message = NULL;
+		ctx->message_len = 0;
+		memset(ctx->curr, ' ', ctx->cfg->num_chars);
+		ctx->cfg->update(ctx);
+		return 0;
+	}
+
 	new_msg = devm_kmalloc(&ctx->pdev->dev, count + 1, GFP_KERNEL);
 	if (!new_msg)
 		return -ENOMEM;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux