From owner-svn-src-all@freebsd.org Tue Dec 13 19:58:22 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9F790C7672D; Tue, 13 Dec 2016 19:58:22 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6EE9B1D3; Tue, 13 Dec 2016 19:58:22 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBDJwLrN099692; Tue, 13 Dec 2016 19:58:21 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBDJwLST099691; Tue, 13 Dec 2016 19:58:21 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201612131958.uBDJwLST099691@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: "Conrad E. Meyer" Date: Tue, 13 Dec 2016 19:58:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310031 - head/sys/compat/linuxkpi/common/include/linux X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Dec 2016 19:58:22 -0000 Author: cem Date: Tue Dec 13 19:58:21 2016 New Revision: 310031 URL: https://svnweb.freebsd.org/changeset/base/310031 Log: linuxkpi: Fix not-found case of linux_pci_find_irq_dev Linux list_for_each_entry() does not neccessarily end with the iterator NULL (it may be an offset from NULL if the list member is not the first element of the member struct). Reported by: Coverity CID: 1366940 Reviewed by: hselasky@ Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D8780 Modified: head/sys/compat/linuxkpi/common/include/linux/pci.h Modified: head/sys/compat/linuxkpi/common/include/linux/pci.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/linux/pci.h Tue Dec 13 19:36:05 2016 (r310030) +++ head/sys/compat/linuxkpi/common/include/linux/pci.h Tue Dec 13 19:58:21 2016 (r310031) @@ -220,18 +220,19 @@ static inline struct device * linux_pci_find_irq_dev(unsigned int irq) { struct pci_dev *pdev; + struct device *found; + found = NULL; spin_lock(&pci_lock); list_for_each_entry(pdev, &pci_devices, links) { - if (irq == pdev->dev.irq) - break; - if (irq >= pdev->dev.msix && irq < pdev->dev.msix_max) + if (irq == pdev->dev.irq || + (irq >= pdev->dev.msix && irq < pdev->dev.msix_max)) { + found = &pdev->dev; break; + } } spin_unlock(&pci_lock); - if (pdev) - return &pdev->dev; - return (NULL); + return (found); } static inline unsigned long