Received: by 10.213.65.68 with SMTP id h4csp247263imn; Fri, 23 Mar 2018 03:52:12 -0700 (PDT) X-Google-Smtp-Source: AG47ELsT7BG4kvq1ymYJYeFAlVu+1r9Eym+bzXASPjlP0RL7vj28fmkCiRRNIldzUydDPG+f13Mu X-Received: by 2002:a17:902:8ecb:: with SMTP id x11-v6mr18829735plo.402.1521802332216; Fri, 23 Mar 2018 03:52:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521802332; cv=none; d=google.com; s=arc-20160816; b=fkKktOEtqULVwl5ewvW/C/bmd35RjsUw+qyE9nWL/TyM7ZtBeXVFY0NDHPDrCxsMnN P4QHR9r5pI74W/Ou7r6dZhendLYiBLwbO7g/XnNafNXLlo6a48+W6x9j+SrougCO+MO8 lB/y+uCkcCphiG1hDUjHMzQgPdj1H1UvDLp8g2a1i9z7CMKhOCG2utMgNVXa9YWnRCxY tA2KBkSFm5vXm/o3WPcvnIpyVemwV9glBjHkosRZ/a3ql10Qi2qH1Gwgo2Qqy2Wtc4S4 AulutBw2zFY8Sb5nx871qAQIiqI7S0/j/vae+T9NlOl0Z/Vf4dH3vf2keFOLj6f1Z2by rXtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=N5MfXRRoHicQqHSOccv5as7Hac2XpcRWEj+v5XDdlnA=; b=RATUi4tyY5oo+JwEUBKFOh8wvR2dLmLTbQ+Mi45AgXX8fsHQyzX0Y9rzq96L+TEOyL wHvjGvUinXppgxvP9RvF21go4ptNHeWa3T0lDIG+47hBJ8lgThZOn9MkME32fybvjUgl QhIfTymm9mrmTfwOJyLWfAXRgG2ieNp8NVuSwUI+um1mKDjuzso5r9+HcrUud/IFgyz0 8H/sVfUC1k/Mk6hCtdYza0dINnMssjAE5sf+f/+aRnyk/Hxz71fKYfBVUNKf3qFPzBjj zuIih9TYmvG5tktKcI9nrxOc7s8iPMyU/Wyn7n/H4L4WjUHRZ6DA8e58xVKevSDUGklc wQGw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z25si5870277pgc.821.2018.03.23.03.51.57; Fri, 23 Mar 2018 03:52:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932217AbeCWKt7 (ORCPT + 99 others); Fri, 23 Mar 2018 06:49:59 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45322 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933353AbeCWKOk (ORCPT ); Fri, 23 Mar 2018 06:14:40 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id E73F0119C; Fri, 23 Mar 2018 10:14:39 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pan Bian , "David S. Miller" , Sasha Levin Subject: [PATCH 4.4 42/97] qlcnic: fix unchecked return value Date: Fri, 23 Mar 2018 10:54:29 +0100 Message-Id: <20180323094200.000267254@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094157.535925724@linuxfoundation.org> References: <20180323094157.535925724@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Pan Bian [ Upstream commit 91ec701a553cb3de470fd471c6fefe3ad1125455 ] Function pci_find_ext_capability() may return 0, which is an invalid address. In function qlcnic_sriov_virtid_fn(), its return value is used without validation. This may result in invalid memory access bugs. This patch fixes the bug. Signed-off-by: Pan Bian Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c @@ -127,6 +127,8 @@ static int qlcnic_sriov_virtid_fn(struct return 0; pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_SRIOV); + if (!pos) + return 0; pci_read_config_word(dev, pos + PCI_SRIOV_VF_OFFSET, &offset); pci_read_config_word(dev, pos + PCI_SRIOV_VF_STRIDE, &stride);