Received: by 10.213.65.68 with SMTP id h4csp304167imn; Fri, 23 Mar 2018 05:09:13 -0700 (PDT) X-Google-Smtp-Source: AG47ELsE9puDmSQ/jECEFIKNPgnHCGw36Lj9DW33TkIGwfFl0V276vxj2n/LRAUurgXNqUAMeQaI X-Received: by 2002:a17:902:9a05:: with SMTP id v5-v6mr29102774plp.69.1521806952983; Fri, 23 Mar 2018 05:09:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521806952; cv=none; d=google.com; s=arc-20160816; b=CI6MVqz9GKGS85kBlbbD3FyhmAb5R5OupCWU5VIvmHUP7aYQ4gPgvKpZvyACMHRb0G pjTDVRMoj/B8gGt6WXlDKuXA6fLD9ze4plNnS/9wuh4AR+TZZH6E+aV0PBvKgoGhd3lg xrVosgoc0crp2pIH2uaMD43W9/axBgUAXaKPXNp/Ulb4SOeolzRBkYsJ2UcGLSXhOhB6 B8Y96et5FmZWD85CXjmirhEJROrl7FI3a5oeJ6vv2b8yJJWd2gF0rQp7+OuQ9uLtWGLQ mxFVqL4vTB1gJlA3pQZ9yXqhXheEUhG9F0I4CMmGka1sJ2qLUl3IuA0AbySzQHN07VHl JL0w== 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=kmSAudrrn9ENWre6Io5ROoto3hBdYeZbS6hgAvj79L8=; b=XOm+WQTr0hLiFu0x6UlccECmj3FwXM2Ip/XbYGD1XzipRvMJsQMn1LM6RSn1yKrfLE fLWqU/W13kZ0BlrJoFfvLviYIL0O2+VYbmwuPl+ZPYt0u2vZDypRzlZRo3RaNUz3BMmZ s5lVAqZKrD0PMnkoa6SAKR7mKJ/WR8klA0GH0rOuDdvp1PH5JDyrNiQIrVmX7C2Tarze YhMj02zBG6KRakQptouPaKN1DE2t5vVUMYtWpUkaAYCbAMyXC8Ky0ws8YoBz2Mp8U1Db i7OlQe6i8nzHDDmB6yIuMgD5JTt14pAxCvtVTzkABcciuuyNI2lPDeUJ/LG4G5hqbU3Y cnlg== 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 l62si1560539pga.144.2018.03.23.05.08.56; Fri, 23 Mar 2018 05:09: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 S1753208AbeCWJ6v (ORCPT + 99 others); Fri, 23 Mar 2018 05:58:51 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:35858 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753150AbeCWJ6r (ORCPT ); Fri, 23 Mar 2018 05:58:47 -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 973341337; Fri, 23 Mar 2018 09:58:46 +0000 (UTC) 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 , Sasha Levin Subject: [PATCH 4.15 52/84] PCI: endpoint: Fix find_first_zero_bit() usage Date: Fri, 23 Mar 2018 10:54:06 +0100 Message-Id: <20180323095419.842070254@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323095411.913234798@linuxfoundation.org> References: <20180323095411.913234798@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.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Niklas Cassel [ Upstream commit 35ad61921f495ee14915d185de79478c1737b4da ] find_first_zero_bit()'s parameter 'size' is defined in bits, not in bytes. Calling find_first_zero_bit() with the wrong size unit will lead to insidious bugs. Fix this by calling find_first_zero_bit() with size BITS_PER_LONG, rather than sizeof() and add missing find_first_zero_bit() return handling. Fixes: d74679911610 ("PCI: endpoint: Introduce configfs entry for configuring EP functions") Signed-off-by: Niklas Cassel Signed-off-by: Lorenzo Pieralisi Acked-by: Kishon Vijay Abraham I Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/pci/endpoint/pci-ep-cfs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/pci/endpoint/pci-ep-cfs.c +++ b/drivers/pci/endpoint/pci-ep-cfs.c @@ -109,7 +109,10 @@ static int pci_epc_epf_link(struct confi goto err_add_epf; func_no = find_first_zero_bit(&epc_group->function_num_map, - sizeof(epc_group->function_num_map)); + BITS_PER_LONG); + if (func_no >= BITS_PER_LONG) + return -EINVAL; + set_bit(func_no, &epc_group->function_num_map); epf->func_no = func_no;