From nobody Thu Jan 4 13:48:00 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4T5Sb526Zwz56R7b; Thu, 4 Jan 2024 13:48:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4T5Sb46BDmz45WH; Thu, 4 Jan 2024 13:48:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704376080; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nAwJNPoFcB6S7nmYyWyeniHDqqylclwnk5KaHLxlQEk=; b=rthuTOYQpG15fwnAQOvPrUDzSDG/yDx3VRTm1Vh/08IsPpOkoxvKyWIzRN9+NdSe5HfjzB p3dLE5Uq87l8pyRgdh4jusEKlWZvGIJmKchrIEqUYuFtfrsYtYQn3vy/yh2YfZCRrKGTwp S+n6vANUsCvtMOcYMBfC33Oj/KyXZaxVxN4QmVeBTdu7AtkUMNFKyfjZymc5C9J+MLk/hn 6hl4jPjnEUKR6FLvtFwkXOG1DK8rlg7QdfjjbuTsY5izjs5j2sH8g9PUOdwEgEP1hLLBtc mqJQnc5bSZhqsVvlRTa7jg+3RnCtm1eOZfVHPNmu56FnolKZXw3uyIEJ5jFnrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704376080; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nAwJNPoFcB6S7nmYyWyeniHDqqylclwnk5KaHLxlQEk=; b=WMGBORHBIVNpTJLagTBH9yhzr7hyEKik8iLEvaG0kTBazpioL42wOcgh/ChiKxwYKdmVra GzdSOYKY5MqWCDT375rkBOPfKzsJne68uHeIkmKFk+t5UXECHkouF1SIm/yjrLHVGOdBex 56hSpiCW9S5mr01dUpgblSM+wdhg8hRDkSxzOeRiMY3D4qKgzjwlOAK6bHrbICFuL+191M gOKc6qYPrl3jwRMdMjIjKzMiQz8LzDd7HPzZTz88mVGZRum7Ff8Me4prT6oy2xpGFHC3f9 BPXiaJh5F0jtmqxuetTSvuR/AH4XNxO1x7uSekQBOW7ou4CP9ZSJZ++v5+/gqg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704376080; a=rsa-sha256; cv=none; b=EHX1+FgblCmNvGGZoTGRrH3M2wDm3QgvdKfyYO/+Yg6IUojXMUO58XGroLSgzj6SQsd+9s g7l3hxg0+ldh5at+IOqY2PfQekEgc6PAKNtcvCprn52+8etrtmD1M3kWWpfWrYxLBvXPDL IuaXmY6vL7JxcFB+rqMPDrQSxWH+fwFJdugYSv2tuhbS2VI4LPCS5tRcAf5i36Dzsf9xbn 7ohz/wXbVtp8p0CLQLlEAo3i62QaLA6W/E7HI7gIVmAN3ZA3ih7DZNb0uscc2A2f2iWn1O mwMdR5l+SIf0lv5c4PhaZQ2bfzMdoSCOws1wxqz4YKKF3Ku3fpXHOw28Jps8Sg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4T5Sb45FwhzGK6; Thu, 4 Jan 2024 13:48:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 404Dm0Nb049646; Thu, 4 Jan 2024 13:48:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 404Dm0Tu049643; Thu, 4 Jan 2024 13:48:00 GMT (envelope-from git) Date: Thu, 4 Jan 2024 13:48:00 GMT Message-Id: <202401041348.404Dm0Tu049643@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 3e53fec0027e - stable/14 - fb: Explicitly handle errors when getting or setting a colour palette List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 3e53fec0027e79e10b1024a42e0ba8fa1aa6bc18 Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=3e53fec0027e79e10b1024a42e0ba8fa1aa6bc18 commit 3e53fec0027e79e10b1024a42e0ba8fa1aa6bc18 Author: Mark Johnston AuthorDate: 2023-12-27 00:00:14 +0000 Commit: Mark Johnston CommitDate: 2024-01-04 13:42:13 +0000 fb: Explicitly handle errors when getting or setting a colour palette In the VESA driver, simply ignore errors. It is not clear to me how to return them to userspace. This is in preparation for annotating copyin() and related functions with __result_use_check. MFC after: 1 week (cherry picked from commit ddc8576d297937a1395f47550a8f5b1fac79afc2) --- sys/dev/fb/vesa.c | 16 ++++++++-------- sys/dev/fb/vga.c | 24 ++++++++++++++++-------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/sys/dev/fb/vesa.c b/sys/dev/fb/vesa.c index ee3409dfa755..e1cca3a70725 100644 --- a/sys/dev/fb/vesa.c +++ b/sys/dev/fb/vesa.c @@ -1698,12 +1698,12 @@ get_palette(video_adapter_t *adp, int base, int count, b = g + count; error = vesa_bios_save_palette2(base, count, r, g, b, bits); if (error == 0) { - copyout(r, red, count); - copyout(g, green, count); - copyout(b, blue, count); + (void)copyout(r, red, count); + (void)copyout(g, green, count); + (void)copyout(b, blue, count); if (trans != NULL) { bzero(r, count); - copyout(r, trans, count); + (void)copyout(r, trans, count); } } free(r, M_DEVBUF); @@ -1729,12 +1729,12 @@ set_palette(video_adapter_t *adp, int base, int count, return (1); bits = (adp->va_flags & V_ADP_DAC8) != 0 ? 8 : 6; - r = malloc(count * 3, M_DEVBUF, M_WAITOK); + r = malloc(count * 3, M_DEVBUF, M_WAITOK | M_ZERO); g = r + count; b = g + count; - copyin(red, r, count); - copyin(green, g, count); - copyin(blue, b, count); + (void)copyin(red, r, count); + (void)copyin(green, g, count); + (void)copyin(blue, b, count); error = vesa_bios_load_palette2(base, count, r, g, b, bits); free(r, M_DEVBUF); diff --git a/sys/dev/fb/vga.c b/sys/dev/fb/vga.c index eb081ae533d7..9851838aa8f3 100644 --- a/sys/dev/fb/vga.c +++ b/sys/dev/fb/vga.c @@ -2854,6 +2854,7 @@ get_palette(video_adapter_t *adp, int base, int count, u_char *r; u_char *g; u_char *b; + int error; if (count < 0 || base < 0 || count > 256 || base > 256 || base + count > 256) @@ -2863,19 +2864,26 @@ get_palette(video_adapter_t *adp, int base, int count, g = r + count; b = g + count; if (vga_save_palette2(adp, base, count, r, g, b)) { - free(r, M_DEVBUF); - return ENODEV; - } - copyout(r, red, count); - copyout(g, green, count); - copyout(b, blue, count); + error = ENODEV; + goto out; + } + error = copyout(r, red, count); + if (error != 0) + goto out; + error = copyout(g, green, count); + if (error != 0) + goto out; + error = copyout(b, blue, count); + if (error != 0) + goto out; if (trans != NULL) { bzero(r, count); - copyout(r, trans, count); + error = copyout(r, trans, count); } +out: free(r, M_DEVBUF); - return 0; + return error; } static int