git: 33e2eac3e3e7 - main - ix(4): Sanitize negative error codes
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 18 Aug 2026 08:24:48 UTC
The branch main has been updated by kgalazka:
URL: https://cgit.FreeBSD.org/src/commit/?id=33e2eac3e3e738daa95a06f42d6c661b87ad9aac
commit 33e2eac3e3e738daa95a06f42d6c661b87ad9aac
Author: Sobczyk, Pawel <pawel.sobczyk@intel.com>
AuthorDate: 2026-08-18 08:10:54 +0000
Commit: Krzysztof Galazka <kgalazka@FreeBSD.org>
CommitDate: 2026-08-18 08:11:12 +0000
ix(4): Sanitize negative error codes
Due to development history FreeBSD driver error codes are reported
the same way as in Linux (as negatives) which is inconsistent
with FreeBSD standard. It may cause unexpected behavior when driver
errors are interpreted by a kernel as syscall handler return values.
This patch converts error codes from negative to positive values for
NVM access functions.
Signed-off-by: Pawel Sobczyk <pawel.sobczyk@intel.com>
Reviewed by: kbowling, erj, milosz.linkiewicz_intel.com
Tested by: Mateusz Moga <mateusz.moga@intel.com>
MFC after: 1 week
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D57642
---
sys/dev/ixgbe/if_ix.c | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/sys/dev/ixgbe/if_ix.c b/sys/dev/ixgbe/if_ix.c
index 25e7e9bdf913..6de2b40e1aee 100644
--- a/sys/dev/ixgbe/if_ix.c
+++ b/sys/dev/ixgbe/if_ix.c
@@ -1603,8 +1603,9 @@ ixgbe_nvm_access_ioctl(struct ixgbe_softc *sc, struct ifdrv *ifd)
size_t ifd_len = ifd->ifd_len;
size_t malloc_len;
device_t dev = sc->dev;
+ s32 status;
u8 *nvm_buffer;
- s32 error = 0;
+ int error = 0;
/*
* ifioctl forwards SIOCxDRVSPEC to iflib without conducting
@@ -1653,10 +1654,10 @@ ixgbe_nvm_access_ioctl(struct ixgbe_softc *sc, struct ifdrv *ifd)
(nvm_buffer + sizeof(struct ixgbe_nvm_access_cmd));
/* Handle the NVM access request */
- error = ixgbe_handle_nvm_access(hw, cmd, data);
- if (error) {
+ status = ixgbe_handle_nvm_access(hw, cmd, data);
+ if (status) {
device_printf(dev, "%s: NVM access request failed, error %d\n",
- __func__, error);
+ __func__, status);
}
/* Copy the possibly modified contents of the handled request out */
@@ -1668,6 +1669,20 @@ ixgbe_nvm_access_ioctl(struct ixgbe_softc *sc, struct ifdrv *ifd)
goto cleanup_free_nvm_buffer;
}
+ /* Convert private status to an error code for proper ioctl response */
+ switch (status) {
+ case IXGBE_SUCCESS:
+ error = 0;
+ break;
+ case IXGBE_ERR_OUT_OF_RANGE:
+ error = ENOTTY;
+ break;
+ case IXGBE_ERR_PARAM:
+ default:
+ error = EINVAL;
+ break;
+ }
+
cleanup_free_nvm_buffer:
free(nvm_buffer, M_IXGBE);
return (error);