From patchwork Fri Sep 19 20:14:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 357 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758312976; bh=zYlUP5JMEgConsanLnwPnG3xfBYvM3RDCBTtpegT0Hc=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=pucGpEGhcHPgNauKW780iqO7o99sLS0TUgnow0xJSxZ66DaVFDpQ0lmddT1ZUBzki M5pqOTw2LoYlNleSQTwKvdx8GnYTB52iBzSB+KodcdG1jG+N8RubwxO49Qrx9uhCrk YdX7wJ9IoXVXFkOUDbXlhPtslhqzdK4FqdpBhRBtEG/6NIAAu7tgvkThORqm7XfN1T Zjkdf7IGzJx7cPUqEn1PmR4B5qDGVR496vLv+HVkWxFTxHAeGxw5xKoNuER8fJ+P7w 5uPaiElW+SbnFPFW4fEe3T+MaBdaG5ek7iLZMwsHudJWKRHi6NRL95Lv+Qne/UDuax V4ADvMDz4bGsg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D18CF67C72 for ; Fri, 19 Sep 2025 14:16:16 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id DAyDIOkqpJIW for ; Fri, 19 Sep 2025 14:16:16 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758312975; bh=zYlUP5JMEgConsanLnwPnG3xfBYvM3RDCBTtpegT0Hc=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=s/2/54ZpC8mNILw/RzjXfmd9kICYpNqjqTMWfLAAl6ER5f+ysOQYfURFr619Eq3Ky S7ZbsjUzAjy3FnNon63oMjlGvuukCYB7epoX3cp1be6aYqPW3Be+aW+DrSQ8w65YvV +S7xvIJpY6Ioncm3CTCeMFpCEVtyvecRpZQ2Wg4kqa+nxrZghnQLwPVVmpTGFY1ey0 CWsn++to3djlFG0IAchSiAa47OVMSD2Trg1zsEbc+DLCzYfdf7DPFzDxY+wHSpMubI 0qdCvN85w7RAz1F9BFui1sPQ5/zbeB4lDfyYs1Iv9edjleYza65pCqA3pgwyx5ZrK+ 5JH6qUGVUwpvA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D60AF67B3B for ; Fri, 19 Sep 2025 14:16:15 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758312974; bh=vfHRO+xroOK1vUP8VFSjADO+0HKFQCPwBEFUyD06zCM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L1aXS/rnv4pEj7D+xAqqHqGkYB6vI4ePL+8nH/sWZ1s73dVDPfo/APdfpf8Tv7hl4 Gy3c3EiKW6KaUNxgPdDxeqNtL0NUD1BgjkwYB98LwYHF5fBzTeyK9DuM+OLrzK01u8 InDK24ddnRalzIImO+rIUJUdHEieWtcENVawm+kjtrLg4lpSO5q+q9neW2ukkZ9GDb Zoimc6vlCSOb/IM/exFVwu0cT31o+gFgNoXjpdoI699VHOkSeVJ6srceKVtNeJC9BK Y6eoeGY1DRROQMNpcB4Kcj1om4GRsFKvlviLSHOe01BQJc4PzDfs3z2nCgXMN8lUM+ l7jA2Kg2lr3LQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2CC6C67B3B; Fri, 19 Sep 2025 14:16:14 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id R0HWBf_vVG50; Fri, 19 Sep 2025 14:16:14 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758312972; bh=WcZWzNsxzRHuiyNrg/TLPAfXBxo577JlFDXTfADN3MY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AQB5SiuZKOHXgIauxzegtIAPDVtQHXnE3+Ncpml3z0cBcVTYO7+YlrD+Y+VocNgWL 2SWq8Mf35ZNZliTLkoDTOWmzydeICn7CyonBrLucfyHeua+WE2wOtO3xNSWJ6onTb3 7VzK3/TPaSDfgnUj4dQSq3dO2D9/x0UBV5XTAB6PquF0BSkQpAa3g25Z4lTxXttjNv HYOVL02cQUQcRFkRSIfyikFgJKrV/dJqrhPwB2wNeh3Gcc2A7/DVMqDOteEwewIkKA zBpRsdx7JUN3/ySN98mcMfQzQ6ofgmh+oE54yDPvnliyaC6nYs2PEefn8bIulNVhcT 7EXrK+D1GX2hg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 76BC267A99; Fri, 19 Sep 2025 14:16:12 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 19 Sep 2025 14:14:22 -0600 Message-ID: <20250919201507.4024144-16-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250919201507.4024144-1-sjg@u-boot.org> References: <20250919201507.4024144-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: HHARKRUA73YWKOBDTB7ANRRLXPHW4MHP X-Message-ID-Hash: HHARKRUA73YWKOBDTB7ANRRLXPHW4MHP X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 15/42] video: Correct cursor handling when the the left side List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass There is normally a prompt which prevents the cursor ever being on the far left. However we should check for this to avoid a potential crash. Add a check for x being at least 0 in console_set_cursor_visible() Signed-off-by: Simon Glass --- drivers/video/console_normal.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c index 9509f81f40f..68d47eb8da6 100644 --- a/drivers/video/console_normal.c +++ b/drivers/video/console_normal.c @@ -92,11 +92,12 @@ static int __maybe_unused console_set_cursor_visible(struct udevice *dev, return -ENOSYS; x += index * fontdata->width; - start = vid_priv->fb + y * vid_priv->line_length + x * pbytes; /* place the cursor 1 pixel before the start of the next char */ - x -= 1; + if (x > 0) + x -= 1; + start = vid_priv->fb + y * vid_priv->line_length + x * pbytes; line = start; draw_cursor_vertically(&line, vid_priv, vc_priv->y_charsize, NORMAL_DIRECTION);