From fadd3f8a66faf682d83a1e0e45c03ba3b21155ac Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Thu, 1 Mar 2018 01:49:36 +0000 Subject: [PATCH] pci_ioctl: Avoid returning uninitialized error value if user provided empty buffer In the weird case where the user-provided buffer was zero bytes, we could break out of PCIOCGETCONF and return without initializing error. In this case, initialize error to zero -- we successfully did nothing, as requested. Reported by: Coverity Sponsored by: Dell EMC Isilon --- sys/dev/pci/pci_user.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/dev/pci/pci_user.c b/sys/dev/pci/pci_user.c index 229515d0c381..6f75f33148b7 100644 --- a/sys/dev/pci/pci_user.c +++ b/sys/dev/pci/pci_user.c @@ -762,8 +762,10 @@ pci_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *t * tell the user that there are more matches * left. */ - if (cio->num_matches >= ionum) + if (cio->num_matches >= ionum) { + error = 0; break; + } #ifdef PRE7_COMPAT #ifdef COMPAT_FREEBSD32