Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2529876imu; Thu, 29 Nov 2018 06:28:18 -0800 (PST) X-Google-Smtp-Source: AFSGD/X46wN0mpStsxbrryeCEomPE8bVuj9w+58sC3ZL782vDxGqJxvRpAQqBXukowVLzU54uhxE X-Received: by 2002:a63:9501:: with SMTP id p1mr1424072pgd.149.1543501698181; Thu, 29 Nov 2018 06:28:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543501698; cv=none; d=google.com; s=arc-20160816; b=LTFkKGkgMHLmxx8gynRfstY2FuS+kgw18DwpgvxiHyia6IgPFG3ba9qbAfaVUKJTj6 MGgcG6MlSjcAYtvC83NECAppHw9LrmJs0TmSAeu7B0qEbZGfWguIbcpxC8r55e8rLQJH vhiGjdzp3kae3aunhCgQZYyzHlM/H7O1q6tJEYE2pvEoxpK5FDKG8L2tDXrEJRiW5ZFw TLvfTA5LSzEAmZ1IuhOKwM6VXHS+2kxMS5pXiqdExrIq59Yv2watgEnBjQyLGlEoWGO+ MdpM3KjoYyfqMHTabEAxELiulqMHzArisnBZebdnlyWEpc+SNCBQi2w4sxjo096auUGK 6GtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PDqP1GtXL+VQqBwxoI9Gzjxtyk/720WPEeurkEcedP0=; b=BOCNHMbYFW5pEIk+vCUZWN3GGZLn1jmDob31sl2ywuXv4jwh9xTQToBpAoMsjQZgrh 9T9KvKDBjZQuwRQABPmqF2ZoM+tCUuzEdRYq/uL1ogJVMRbXC9pkjJvZI5pRfaMZ2C2a k1I6WzrKvfSeTYwyddTWpneUYoF8tkYCD45mYCwQJw5WkhJjume5ubkx88w7uzrndCVC gE8+Z7EpxYMxisY7ie3Bome9/n8OjQuDOLP2qBKTTwNN0wxnovxFbGBssGZDIh6pVMV5 3Pfaz1yNl6ciAq79JSYHlIztxkXntfz1f2e7WOwAs7yTDZqDalT+b3QpB2bath7o2pP4 bzXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WGvHlUQF; 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 v19si2305040pfa.80.2018.11.29.06.28.02; Thu, 29 Nov 2018 06:28:18 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=WGvHlUQF; 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 S2387702AbeK3Bc6 (ORCPT + 99 others); Thu, 29 Nov 2018 20:32:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:33254 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731824AbeK3Bc5 (ORCPT ); Thu, 29 Nov 2018 20:32:57 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 893072133F; Thu, 29 Nov 2018 14:27:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543501645; bh=sbqqnKAeBKOEmOs+5xGo33vsAzEceMfzNVIT3FLh5HE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WGvHlUQF5vI3jFeVe3/v3izpDhVYK9l250JH3g10YMKLLDb4CVvkLPAcuorCWfSC/ toZozDz3Ly5HFzFhQoaezTK81zQVnCXYpxV+6pv7oLq2+Pnb2yg75FX06hEnwVnRaU B/bHBdKxQLleWWR+/WNC+wU78cG5T9VK438gmB+U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Niklas Cassel , Lorenzo Pieralisi , Kishon Vijay Abraham I , Sudip Mukherjee Subject: [PATCH 4.14 081/100] PCI: endpoint: Populate func_no before calling pci_epc_add_epf() Date: Thu, 29 Nov 2018 15:12:51 +0100 Message-Id: <20181129140105.765963444@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129140058.768942700@linuxfoundation.org> References: <20181129140058.768942700@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Niklas Cassel commit 0c47cd7a9b6c9c36c08113e594e9ad017fb17865 upstream. func_no is a member of struct pci_epf. Since struct pci_epf is used as an argument to pci_epc_add_epf() (to bind an endpoint function to a controller), struct pci_epf.func_no should be populated before calling pci_epc_add_epf(). Initialize the struct pci_epf.func_no member before calling pci_epc_add_epf(), to fix the endpoint function binding to an endpoint controller. Fixes: d74679911610 ("PCI: endpoint: Introduce configfs entry for configuring EP functions") Signed-off-by: Niklas Cassel [lorenzo.pieralisi@arm.com: rewrote the commit log] Signed-off-by: Lorenzo Pieralisi Suggested-by: Kishon Vijay Abraham I Acked-by: Kishon Vijay Abraham I Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/pci/endpoint/pci-ep-cfs.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) --- a/drivers/pci/endpoint/pci-ep-cfs.c +++ b/drivers/pci/endpoint/pci-ep-cfs.c @@ -97,16 +97,10 @@ static int pci_epc_epf_link(struct confi { int ret; u32 func_no = 0; - struct pci_epc *epc; - struct pci_epf *epf; struct pci_epf_group *epf_group = to_pci_epf_group(epf_item); struct pci_epc_group *epc_group = to_pci_epc_group(epc_item); - - epc = epc_group->epc; - epf = epf_group->epf; - ret = pci_epc_add_epf(epc, epf); - if (ret) - goto err_add_epf; + struct pci_epc *epc = epc_group->epc; + struct pci_epf *epf = epf_group->epf; func_no = find_first_zero_bit(&epc_group->function_num_map, BITS_PER_LONG); @@ -116,6 +110,10 @@ static int pci_epc_epf_link(struct confi set_bit(func_no, &epc_group->function_num_map); epf->func_no = func_no; + ret = pci_epc_add_epf(epc, epf); + if (ret) + goto err_add_epf; + ret = pci_epf_bind(epf); if (ret) goto err_epf_bind;