From nobody Wed Dec 27 00:06:17 2023 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 4T0Bkf0RSrz54bkK; Wed, 27 Dec 2023 00:06:18 +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 4T0Bkd447Mz4JqQ; Wed, 27 Dec 2023 00:06:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703635577; 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=ajRBlBwTE6F+/RhyMpNS7mA0S+qJkmYkOUM4mHwI6G4=; b=eQNERyd6xPYvuRqravG6lnWqRi8DFxOPBx5LVGkcZYejqWLFVkNR2wR55YQiBd+ovJauao 5CKoANuUUUmrd/a7jSNIr5a+xCLCtGhdyiaD82nkjnDWrjb+nyLKyqn1+ZLjKLhHeJHqkR XNrSjkClfPXzX4TF0KRzybTJ6GVYPndCK1xOC9rCtECARHAvwwuMug5mL24PHvnI1K6sQR hLvXp1T7Gp/Rjof9YhE+XVYj2Rkr75f0Sk+bffv50n414xvcEeVQ4taNiiL6KeVcS7Mx5X 3urJn1DuPeISRU1co6CKJogz50KsedQdykrhS4HptWEHpcPiWv1DPzY0vPJ1+w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1703635577; a=rsa-sha256; cv=none; b=TDArtjO8aycivlgFpEy9J5kzWVM6LrqZaIpYg8ZKLOXd587pUurCNwBvvuOyMhR9ImC3X1 CBOt+Yt7d5WFrdWq8XmdJAfWEp/9p9z+VyEui05osDic1bKLIuUyXmWgxJ/BMiFcpcUZBr PMesbRZGylRYo8r5hyD5pR8KVaeT4dxhPZrMBNsXSMyRhKz+ZNWvlv0arNmCoMAQxUVXZP 4oE6cKtJGgSDzq0gymoxM1s4HoM9sGfgZ2qOmY2SHKt6OzYCH/xGuaztcAy+OpMZcCmo2H IN7AvEQ9aSEUuUG2FhrmicGTraS9MMU3kt7lmNmffuDG09ukN1HobWpYB0dEjQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703635577; 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=ajRBlBwTE6F+/RhyMpNS7mA0S+qJkmYkOUM4mHwI6G4=; b=Hw0jFFVn0GrdWTOyPNHgQB2fEtESisu3RVcQ20daQeT+YFCqxkxwZbbwu2X2BbBV5xAMac kBUEYTTLRPThT8wUM0ZsAXJ3mSyWBoz/4DNOYCvSXI0n0w1OcTsKSQLpNbqb5xoC4JO2to RfKnUJu+IV46z9mWMMfcU1pauSZLiMh69B4/mYQsLciwn0jHKWTokqUkBJlPm6Z2kjuiaW FMSzLx063TvZNmbwf+Wm4ts3OnejcspALOy1HdtEe9aoTidlvJpNKXbe5jsHQw3yK8FBKu dHmVaaV1IXgdnHbVB2OIKFbnr7r0ONJdGosoAvvgA3GOEF2R/ysXA0UeoC3j7Q== 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 4T0Bkd2vB0z22r; Wed, 27 Dec 2023 00:06:17 +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 3BR06Hud018918; Wed, 27 Dec 2023 00:06:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BR06H51018915; Wed, 27 Dec 2023 00:06:17 GMT (envelope-from git) Date: Wed, 27 Dec 2023 00:06:17 GMT Message-Id: <202312270006.3BR06H51018915@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: ddc8576d2979 - main - 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/main X-Git-Reftype: branch X-Git-Commit: ddc8576d297937a1395f47550a8f5b1fac79afc2 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=ddc8576d297937a1395f47550a8f5b1fac79afc2 commit ddc8576d297937a1395f47550a8f5b1fac79afc2 Author: Mark Johnston AuthorDate: 2023-12-27 00:00:14 +0000 Commit: Mark Johnston CommitDate: 2023-12-27 00:01:26 +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 --- 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