Received: by 10.223.185.116 with SMTP id b49csp5960113wrg; Wed, 7 Mar 2018 22:41:46 -0800 (PST) X-Google-Smtp-Source: AG47ELvFU67ZJ/xmWK1IL250IrtNjqAE6a2WRBy7Z3/IVbm5j4gmHxZ+cNfCT49/goIROqfZDcq9 X-Received: by 2002:a17:902:6d0f:: with SMTP id s15-v6mr22818061plk.375.1520491306192; Wed, 07 Mar 2018 22:41:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520491306; cv=none; d=google.com; s=arc-20160816; b=Klb3TC3g4e5P5PprBvHq6BHhlTnp3rKD0lC8v44lVgab97hotmc1dGI6avPLMTzAHp wPn0QRbEtg0jlcqFdIAi1KzwbQB6yLK/F2IObl/qj3TKG/ppEkjYK8B0K7zDF9HU/7IJ W6SztBMerMKdsujRnN2leZi9azfWiQpxV0BfOKtNUV67TWeIob2fzvIWnlxms3rx7WBz 4nygxZT0wxQPgEo7DUNB3yqHjB68+BMTz0sj8++GIl3OtO9f+P01wDyQgCluVbVo4vKa 7ioJt7xUA9ZhWWHl+b4VX65lS9rtqPxuozeuJf89atelrnNcSVzM12Dgf4wkY+eF7eRD urlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=wy1dj2uCW4bMNggyVlCxM8KuvBCUUZQOm/qxDp1Uio0=; b=zdrjVbi7OSZDDn8ZsvU+y+wUnRTrTjRsrtjLpp9z7088He9YGGSZrieSDFdbr4YZbb 8EiS5kuotm/Hg1XtGnIUsl/0ChFAGCLUGe0QRw58ZBfn3tOjBXNJRTuu/idjrG3xXfq6 PniW4oJLD/7VWjjRV2qqKcmD5W6GZzEfnrJVMO2NtdZNejdUVc2t+fhrsDJNSPLk0q7A k4F7MtVwsfgeebXvI4pj3c7uZ8+zqtWIx5C0dYzovTJJgkBdWr0qtqjlpI3L01JmGQTJ cXi19V1xpL/JPXfzo+MSLhfONgIlzh0Ml8FZWpLmZEm1bO7t5uStqrB+g6MELEdHXYQ3 8d8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=eRGAMVv2; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b126si7067375pfg.7.2018.03.07.22.41.32; Wed, 07 Mar 2018 22:41:46 -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=@microsoft.com header.s=selector1 header.b=eRGAMVv2; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965480AbeCHGkl (ORCPT + 99 others); Thu, 8 Mar 2018 01:40:41 -0500 Received: from mail-sn1nam01on0106.outbound.protection.outlook.com ([104.47.32.106]:14491 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965301AbeCHE7J (ORCPT ); Wed, 7 Mar 2018 23:59:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=wy1dj2uCW4bMNggyVlCxM8KuvBCUUZQOm/qxDp1Uio0=; b=eRGAMVv2WhRIRFNe5JEuy6KHHCQicg69bIAFJ0xjDOg2WghNr3IQ6iW31lqvmrjoz0XhKfCAQlPninzV9t03BRb1KuBPRw/V9Zv/D2QnUhmgTRsVFqWegIAcpjqa1LQc5+JewfM0J6YboyO2fhcl302I1u7YSEHF6hy6LGtZ8/I= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1015.namprd21.prod.outlook.com (52.132.133.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.588.3; Thu, 8 Mar 2018 04:59:06 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8063:c68a:b210:7446]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8063:c68a:b210:7446%2]) with mapi id 15.20.0588.008; Thu, 8 Mar 2018 04:59:06 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Niklas Cassel , Lorenzo Pieralisi , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 47/67] PCI: endpoint: Fix find_first_zero_bit() usage Thread-Topic: [PATCH AUTOSEL for 4.14 47/67] PCI: endpoint: Fix find_first_zero_bit() usage Thread-Index: AQHTtpoD4AsLVTHbzE2OVZKeiAncFg== Date: Thu, 8 Mar 2018 04:57:52 +0000 Message-ID: <20180308045641.7814-47-alexander.levin@microsoft.com> References: <20180308045641.7814-1-alexander.levin@microsoft.com> In-Reply-To: <20180308045641.7814-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB1015;7:IJ8o7ca/D4YaekeMh1xb8+zHVI8VAURyaYM58roWIc89BtK2FqDCZ5TJGRSKWI/jFYl9CDFM7Pomq/LLrbPm6oPo5Fx718Drq5OdqPP7jhHAPIrLqG2o5+o17xUZuxqd+VtjZVIhgGRpT8+Y1GAJuWXxy9DtkDbc6j2QEpFTOEPxD7HcUM/NV+zRPdmM+CG6qpsGN7en0PxVdv1EaoqkY78yr3OCx9obk5dhPGJ3Pa5oJmqQYym8ub4eTqqpyrKt;20:7WnyC5pBjdQeshrYaz+bSz79nTkPUZZpqDIBgnXkAAlRu0eb668021vUHrMDJDhr2nscSyZP+8JVUEAUIQOnD56LeO6i7Upzjz9vhttrSK17ugL40NLbXi3b7ffgIUGNc1GLIVfVEIWCFPbc96HeoucB1/3g22YAf8hEGoL4Bfk= x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 929a92dd-9e55-4bf5-1146-08d584b15255 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1015; x-ms-traffictypediagnostic: DM5PR2101MB1015: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(180628864354917)(31051911155226)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040501)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231220)(944501244)(52105095)(10201501046)(3002001)(6055026)(61426038)(61427038)(6041288)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(20161123558120)(6072148)(201708071742011);SRVR:DM5PR2101MB1015;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1015; x-forefront-prvs: 060503E79B x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(396003)(366004)(39860400002)(39380400002)(346002)(189003)(199004)(6116002)(53936002)(1076002)(107886003)(3846002)(3660700001)(10090500001)(6666003)(2950100002)(2906002)(6512007)(99286004)(8936002)(6486002)(76176011)(6506007)(68736007)(59450400001)(316002)(110136005)(81156014)(81166006)(8676002)(54906003)(3280700002)(2900100001)(6436002)(97736004)(72206003)(25786009)(10290500003)(86612001)(4326008)(305945005)(7736002)(66066001)(22452003)(478600001)(5660300001)(86362001)(575784001)(14454004)(106356001)(36756003)(102836004)(5250100002)(105586002)(26005)(2501003)(186003)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1015;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: krkCR+L1FGsso4lILRAdYMsYQ/XS5QNxc83chbQ6P802maNTjFUO6bNTDyI1PbvfkedXhU5GjQ++JEKS66e6UsNHml6kWbfBeclE0Kuw2hgdeJlKpkqUsii747A6xfc0kGlzj2h9dV+CJApP5UkgacmgdmJnaTt0Sg4qrQp+iOftmB2M3jNq7nw6QKesg9Doh5UtOxEZDMzkDwdDPIGG+PV3tctkB9NrrL8JE4+S6hC1ZFRMvuXLqxThqc51ojFAZ0yvcCZe2iHDFQLNRpzjZ2dYEbhGoi/HF2O3ECNYSRIlAM7XHZN0fscHLnA9SkCzecrdPKtUSPxEjzz8cZmciA== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 929a92dd-9e55-4bf5-1146-08d584b15255 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Mar 2018 04:57:52.0281 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1015 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 configuri= ng EP functions") Signed-off-by: Niklas Cassel Signed-off-by: Lorenzo Pieralisi Acked-by: Kishon Vijay Abraham I Signed-off-by: Sasha Levin --- drivers/pci/endpoint/pci-ep-cfs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/pci/endpoint/pci-ep-cfs.c b/drivers/pci/endpoint/pci-e= p-cfs.c index 424fdd6ed1ca..16cec66b1d0b 100644 --- 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 config_item *epc_it= em, goto err_add_epf; =20 func_no =3D find_first_zero_bit(&epc_group->function_num_map, - sizeof(epc_group->function_num_map)); + BITS_PER_LONG); + if (func_no >=3D BITS_PER_LONG) + return -EINVAL; + set_bit(func_no, &epc_group->function_num_map); epf->func_no =3D func_no; =20 --=20 2.14.1