From patchwork Mon Apr 24 22:15:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 9697319 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9D9D5603F3 for ; Mon, 24 Apr 2017 22:15:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E96628415 for ; Mon, 24 Apr 2017 22:15:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 830A028423; Mon, 24 Apr 2017 22:15:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 34AA328415 for ; Mon, 24 Apr 2017 22:15:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S978720AbdDXWPr (ORCPT ); Mon, 24 Apr 2017 18:15:47 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:34417 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S978779AbdDXWPm (ORCPT ); Mon, 24 Apr 2017 18:15:42 -0400 X-IronPort-AV: E=Sophos;i="5.37,246,1488816000"; d="scan'208";a="109414101" Received: from mail-sn1nam01lp0117.outbound.protection.outlook.com (HELO NAM01-SN1-obe.outbound.protection.outlook.com) ([207.46.163.117]) by ob1.hgst.iphmx.com with ESMTP; 25 Apr 2017 06:29:39 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=f3YG/14IPY+ZyHSWQE8qnZZDbZBgyGimesRMaypLjdA=; b=sbMXEy50PI3EH32Pcx9f2G140yjZK3wlD3Bc+71voXKPMQ2cDBziskaw9vsvr/CT6EDUJgq05rpIkD1tMrLEyIz8fuD8ygNw3O0eHnbuh6T/Pxpo1rX33HzAErAmIZtrU5FMC3hexI5SvBZo9aZqo879FDYphozf+t3F8GzbFFs= Received: from BY2PR04CA0074.namprd04.prod.outlook.com (10.255.247.42) by CO1PR04MB410.namprd04.prod.outlook.com (10.141.74.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.10; Mon, 24 Apr 2017 22:15:36 +0000 Received: from BN3NAM04FT047.eop-NAM04.prod.protection.outlook.com (2a01:111:f400:7e4e::205) by BY2PR04CA0074.outlook.office365.com (2a01:111:e400:2c16::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1047.13 via Frontend Transport; Mon, 24 Apr 2017 22:15:37 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.21) smtp.mailfrom=sandisk.com; mellanox.com; dkim=none (message not signed) header.d=none;mellanox.com; dmarc=bestguesspass action=none header.from=sandisk.com; Received-SPF: Pass (protection.outlook.com: domain of sandisk.com designates 63.163.107.21 as permitted sender) receiver=protection.outlook.com; client-ip=63.163.107.21; helo=milsmgep15.sandisk.com; Received: from milsmgep15.sandisk.com (63.163.107.21) by BN3NAM04FT047.mail.protection.outlook.com (10.152.92.232) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.1047.9 via Frontend Transport; Mon, 24 Apr 2017 22:15:35 +0000 Received: from MILHUBIP03.sdcorp.global.sandisk.com (Unknown_Domain [10.201.67.162]) (using TLS with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by (Symantec Messaging Gateway) with SMTP id CA.66.29323.3097EF85; Mon, 24 Apr 2017 15:15:34 -0700 (PDT) Received: from milsmgip12.sandisk.com (10.177.8.100) by MILHUBIP03.sdcorp.global.sandisk.com (10.177.9.96) with Microsoft SMTP Server id 14.3.319.2; Mon, 24 Apr 2017 15:15:31 -0700 X-AuditID: 0ac94369-1d7ff7000000728b-9f-58fe7903c78d Received: from exp-402881.sandisk.com ( [10.177.9.6]) by (Symantec Messaging Gateway) with SMTP id FC.87.18148.0097EF85; Mon, 24 Apr 2017 15:15:31 -0700 (PDT) To: Doug Ledford CC: Max Gurtovoy , Sagi Grimberg , "Leon Romanovsky" , Israel Rukshin , Laurence Oberman , "linux-rdma@vger.kernel.org" From: Bart Van Assche Subject: [PATCH, untested] mlx5: Avoid that mlx5_ib_sg_to_klms() overflows the klms[] array Message-ID: <8992bd28-667f-94b1-e582-106e6b41aa4b@sandisk.com> Date: Mon, 24 Apr 2017 15:15:28 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCLMWRmVeSWpSXmKPExsXCddJ5kS5b5b8Ig8PLDS1env/AanFj8VoW i5N9/5gtnh3qZbE4/+EVk8XpRwfYLda9fs/iwO5x/t5GFo9n0w8zebzfd5XN4/MmuQCWKC6b lNSczLLUIn27BK6Mmc0H2Qreclb83DCPrYFxFUcXIyeHhICJxMGTrxm7GLk4hASWMknsevye HcLZwShx8lUfM0zV/EdzmCESixkl/p5/wgSSEBFQk9j0ahE7iM0s8JdRYsanQhCbTcBI4tv7 mSwgtrBArMS547PAbF4BO4mGhl5GEJtFQFXi+eRXYHNEBSIkHnbuYoeoEZQ4OfMJUD0H0ExN ifW79CHGy0tsfwtxg4TAMlaJ5uMQe4UE1CVOLpnPNIFRcBaS9lkI7bOQtC9gZF7FKJabmVOc m55aYGiqV5yYl5JZnK2XnJ+7iRES9pk7GO8+8T7EKMDBqMTDa8DwL0KINbGsuDL3EKMEB7OS CK+ePVCINyWxsiq1KD++qDQntfgQozQHi5I47zmZqRFCAumJJanZqakFqUUwWSYOTqkGxg6h BZOWJrj6dq41YVP03GApdKsyozSon409SM51JR+/0/oFJdwWTK9OPhTYeUIoQXGl08kbepeX 893hKXxroPktgDfG4NnSujdFq7Ybzc01fpW3L8gllHGdwovFP4L5dk39OWdfsMDnN4sLZp6d ovj949R4hcP+rw5xRgfv+hs9PfTRbbuNv5RYijMSDbWYi4oTAWNTsuN3AgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrDJMWRmVeSWpSXmKPExsXCtZGTTZe58l+EwavbAhYvz39gtbixeC2L xcm+f8wWzw71slic//CKyeL0owPsFutev2dxYPc4f28ji8ez6YeZPN7vu8rm8XmTXABLFJdN SmpOZllqkb5dAlfGzOaDbAVvOSt+bpjH1sC4iqOLkZNDQsBEYv6jOcxdjFwcQgILGSW2vGtl BEmICKhJbHq1iB0kwSzwl1Hi6dfJLCAJNgEjiW/vZ4LZwgKxEueOzwKzeQXsJBoaesGaWQRU JZ5PfsUEYosKREg87NzFDlEjKHFy5hOwemYBdYk/8y4xQ9jyEtvfzmGewMgzC0nZLCRls5CU LWBkXsUolpuZU5ybnllgaKRXnJiXklmcrZecn7uJERJ+UTsYr080P8TIxMEp1cDYb1QiwrNp 3d3NqofC9sc7qHxyidr+2n/176pe2XXFBletlKQ3r90g/Wtnp0Dsk9n83+9ftPm9u+Zwde5t NdHClUeVnk3ftO/y7gv/Kx0PP5W9EL/IJPDZeptOk56ygkNWFtyz9jhdvlH9yJDn4u09rEyX fsi5zv0ePetuxIuuFR9jj1q+ap/grMRSnJFoqMVcVJwIAJjCH5TvAQAA X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:63.163.107.21; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(39400400002)(39850400002)(39860400002)(39840400002)(39410400002)(2980300002)(438002)(199003)(189002)(9170700003)(83506001)(6666003)(305945005)(575784001)(2906002)(8676002)(64126003)(6916009)(81166006)(53936002)(31696002)(86362001)(36756003)(4326008)(50466002)(356003)(110136004)(38730400002)(54906002)(31686004)(77096006)(65956001)(33646002)(5660300001)(50986999)(54356999)(23676002)(47776003)(53416004)(8936002)(189998001)(4001350100001)(230700001)(15760500002); DIR:OUT; SFP:1102; SCL:1; SRVR:CO1PR04MB410; H:milsmgep15.sandisk.com; FPR:; SPF:Pass; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN3NAM04FT047; 1:lqsKGfuEIn7kZ8VWyR6lZN6INQ4fUwAQk9k9qucfFGKM/R9eYGNz3HP+2zRALCvQ3XRH9Ax5ej/XZTGnWGs2V9xUN/oWdDBk8gZYOqj/WzHUqTEKC0s4NVKGfKPn3jTHO+6888uqsXYZRByKdwQV0l9mIeToqEeGfVaW9Pfjyo/oNBjYwuB0nl1J8j2IIpMkDNj1GBHt4h9ca4SnRtHBWbdj8P44EauzSMSdzuFetnUE1LzQMBOQg6CpL+G4ssCag9D/C+ERgKFS6q/fiQiceeYR3nB5gFEs3j2Do+ckKbl6L5V7uhGvMTVvt60Woest2HdwIqwUJ4NPkM1cvv9A1Ncu6gsn6W5ttGk8cmMOQ7szbsZjKH72CvDE54hmz+ewFU+Vw6wYtxPimSBt/kKPaLn0QwSmmp76dhApuVCh/22+4wNoxPWRJCd38WhpjLokUtkMLdnbagrq+UsCO+Wo+JO3ffLHzJgzcRPzTZyOgy2pgM9WfoyIBPKWMAOaxTTpfSdJ7/91VLhODcRgBSfA/xoHDdtjT8dpGjYuNOsFGaARHb7/ixE1IEIS/riuZnLy X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3c84ae04-45cd-4483-3f0a-08d48b5f6e9c X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(8251501002)(2017030254075)(201703131423075)(201703031133081); SRVR:CO1PR04MB410; X-Microsoft-Exchange-Diagnostics: 1; CO1PR04MB410; 3:XJ6J5PLrPy59S2yUvZfFCgOlcupR7RfWG2haW+nBQ4K3X58deAiOE1Hp6Ccy4GOyJDxBMTkYbXbcEPuItavkFmVe4SR9soERbMquq+LIyA1jGuXFKiPpIzETpBUksA8CIkhcLz8CCnW/iT+6dHPxMT9AkaRdOztJM9sdEUoLCQQ2zPdK3NQRE91vdD7ZRz8mbeLRnkU/0jn2uLbWL3FnHMEPVZqBU/TVyaQ/Z3waGzfyHzIsm7OaaDmhs4nXkYwLVN622yig5lLAXgpzTEzr/LheA5g0qGd6jIk12rccOdb3gqVSlVUTK9RA/7dmgEKprj7R9nMzHoWk69Y8r6goySePqt+TmXcCTi0hmHjYQXDooRqLRL+M7wrTo6bi5Q9GliFMUSzWMSyWp1EG3S9CeYK9q5lWd5QOBolL8Lmw95r7tR440gytBDlsmLme9o+aGkFtUoGUoVC3dnv35B6D4FL240yciXSRCQOx7ztjtIWOuoRKc+/5biicHSBC80Og X-Microsoft-Exchange-Diagnostics: 1; CO1PR04MB410; 25:h1Fm8uwciK4544AuwKAppb7SPmTuhg99pDYgRwAymLgOmX4ERv9nyYMPSKrxB08OYeax7+kD2C9TX9tNaX614KHslTG8tZCI99MAHuiFs+5pH4rNIzvfWUb+f3SYZwclAPz2eVqk2iAD4AqJrqySZe26gjhHMXfbrUH471kqbe156OkSOSoIobx8OIxYG39sUYFTlAVRL1sSwVoixoTj9lkTVFAUBh5BsJM9KQEPoYl1lafgvlWvISVIuD6Xhg7bCWXnTIju8XVgXbgCR3Br/LXi2bUQaA4uqSREJ5aGKonLv82NiBMEBrPG0ztppuZha7AvFBHxHkm3n9aHHwVGESLKUFF/MZKhmwS6uDsc9+NP9JrFej3HKH1hItNzY75z4xckBJIfgvG6B+2siDfQX8yQINWlMDhdTbhYz+5anGUh/0AHoudI1eAUITDn1RdDMTlmIAvTW4Qa1663z0v0iQ==; 31:NS6IIV2/LQyD1bzZMR1lF7aEd2XCo1ceYTukSKNcED1ZrwCfVi3Wq3TIkGEUgVQAE624SB4k64onH1umkLSqMSpPxNkt9ajc5lUZ0FbkVulFDYTpDRqcrs2swsJ9ptXiFA1R594CA/EYM84efBxb/IO5BbeZh8Quo9fFq4WCrykj1bws6ZU/g/mPqaGt4yQBwEq7S1Hh/96Fb3LqCNxMga+GvhKGIaJDR0BbzYD3FoUwWoZuwbkkaPyXTRbYwI3MBbKnxGIvFClNjIV8h1QqSw== WDCIPOUTBOUND: EOP-TRUE X-Microsoft-Exchange-Diagnostics: 1; CO1PR04MB410; 20:8pAIWLXLAtpnYyf8S9IUklQacvMsPqFjtT1UMPdcfq5vxakEfcRPfNfqs9FxMdK2Wde9SrjrF8U9cVz0HpEd1XCWMoMfy5h+w0+rjLID1S5039glfKIRndbOI1/iW/q0hl5XA1sgZDXQAdMkL1VzGz2UKAJJzJYUpQQROZWOHJWQ0nNGGQRyT/MVTrrWEBjZV/7TygVbC5F+DyYc12TiPLGJHdBYdd7u/6UPyRO57NIJ3ATRleBbiOTegR2QjAXsGY8gUyaQXtWqHwEKxE59M26XJwM4awkacFfHZXGDW+CV+XOP00qTgNc1dPu0DKsLPTVLFwvF9azYj01u6pVpjDgduFvdBVljuWNwhguFotvA9Or6+4d6KdjxflFHRQqS1hlOzrCp3P94uIPAVDbzxbsHmUMuUC/8BRCse3yX3/T9pmaR5zgf9xJRdMgMsSZ1kmzP8u0Ps7uIarkxy71BrH5JLABzzWcFmWMPU8JU7h8QkQXNguo/v/High1vYi78 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(131327999870524)(42932892334569); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(5005006)(8121501046)(13016025)(13018025)(93006095)(93004095)(3002001)(10201501046)(6055026)(6041248)(20161123562025)(20161123560025)(20161123555025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(6072148); SRVR:CO1PR04MB410; BCL:0; PCL:0; RULEID:; SRVR:CO1PR04MB410; X-Microsoft-Exchange-Diagnostics: 1; CO1PR04MB410; 4:erIFp5EIHM4EO/0IBixfxwFPC57Db8s2hwQo6Z+zbWSQSgxjpIrDtzby2JM/Rl1HP0+pjytI5biKDpTA+lpxSc7GBGwsdd1iCVLwfLF4j2jZN4y0xThKlZkDm4AWuIAMZrwY9uiL3ggs5RQYUhA+mwlvfbEa5qj9yAu4ImxLLk1yGX5sauMAEPg55QcpjqQQPVMqzBQY7heJpl3+BeXP6Mj5kpj87sBtf/zMLhfqOxFD7c9pqxPUwydSdOM2/1XubtfoxfF/5Y5L4pay6d4JJKfSjuwyGjlAl0/3ymHW/nirvvY62VwgM1Ct37+wnbDLl8VrcxGixNUHbUnxFi8iiAQbB+hOYiqjHyqBG6L75nRSmHj7NL+Slo5Zv6UYwCj/qV5ejTtAv7DZh+VRB2aABX5uQwta/17VuXdnGE/4di1VCDz22aT/kHo9rMydUlDGqAGOzrlXUDVCvwWJ0cT/T4BLv9SsOrcB49lW/5meFqgHSO8fxWHi1MdgoUST9xPbKwuDQY3llD6Frej2rNCMKLnF7dkB72ITPwXAWC54NyntKvo3xCQ1zKghOY9EpQo4Gglut+ZXyxk+k0+4cyIRpNEPNeRUCTMo9lecdW3Upou1/7u3sx+H0UuVyPTiKECxkpLJwU+sQEN5khopO4wfOoAXS+DEJNY+LWL+bWoAbYQN7MztmDnSwnn7dp2ONDgRKL/OxYDmmVb2EMVMs8dPKc7HnB8DuXD5W9sK53uZk8gaQGNMOCKp9LLx1l7NvjPFp4XMyhhVhecGVjCWAiuH1bCBHLXfM5hVP+gN3J6Z7Ml6UclT4nhUTZRRQvwVPJHjTYE/qS7Ir0lC8C13o35xLxQ/YFgUL9JcO/VYdrR6HcYm3JKG1+CyznXGD1+AJ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eBUYZufzAu/Lhzzs9qQibIxPNJlsa/ELoWdsiXEkwzAzeZ516PShZT4ORO5rxK0HJeo30371dyCofI74p/KNFqULgQGyuH9+7QMCIzt5wdOSINVWCaeA1EDfAiFjyv43WokRpSqkMbQE7C5diNPI2GzjMtcdMp5EEbQRaY39heVe7wqVw1UiHkrrBiHbRhz7oSCBmvovURsXG00uk+RGYlvV1in2VAJIsNT/Ap6GUlUsw695mMRQCNAowDGKNVinNCu6iBsEM73QcPU3klvR4xsO/QXR7O1ET1vnZvXeLTa1I5fFTzpN0oyhlGq0TmMpHZJZR5vDQyX543huwoiRml1aeoCtrIP5yyQ9DlFUjcBU9l7GenEecldWQovpWjzWM=; 5:mD5ytXc8R/vUSt8vrtoiUe446NKmecsi7CscObajiQGmZu52ivp5EsGBPOHSMJSckJxlHrH5QpcgUVb2pczls4WkqLN+QTYxQFGk9VHIfAwbP+jwkhncGcMdu5MSNcSoD0y8DeObAScJcVideWkLpH0HWsmpbuVxgSDpH+B7ljw=; 24:jVmX0sNLG6DFrMFvZkV8UsXGkS2n7BUB7q8ZQ6ZhjX/I2KSONY7a2hA6m7kZL50as2yWlSV1NLso6vW+5FzHMAoYTehytWz17eSqF/w5vJ4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CO1PR04MB410; 7:Ig4HO3Uej3GP5rY3mK2z70JBMMcaEXSQY6Bp9CbdvC0Uf/bCAdgMReWCBnRGAec3uoHE9VrpqxHBQxXoMdLrJdDKjShyi/zQM/IEfpVHEz0cNfWU0F2oFYKUwC4TuLZcx6/gqZRuA/oFzY/9U6KV9DbJy+Dstos84pnUxb7VkXQPEI3ij1oeaJnmedC2j6uu+TE5rxp3YyU//xTXeYkjbayDbw4jn8TRre4jssOIrgvpU97PtvV/38U7BtRK5xj0vXQyF+dAqxgWYDRHfUzen8GwPecjxGzODfWFPSptD7ohpl0lX9r00d2WQwpjRc70REbR0IFoAv9d6ailxD58Ag==; 20:Ko1th8i3RE5zckurNycCeZ1Iquw5JslPeyBLboBQ6G/xOIxxKEgoaPbTl3CL+s9nt5/frRUL+BF2PtDFIbCAZYbjcDYCkU5T72XyfpsPVcwxBirh8kY7PQAaHporUvD9UkVfWHmSjMD3bxPadXVQo0rOsehh91jVro3bb3yLNVw= X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2017 22:15:35.3528 (UTC) X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=b61c8803-16f3-4c35-9b17-6f65f441df86; Ip=[63.163.107.21]; Helo=[milsmgep15.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR04MB410 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ib_map_mr_sg() can pass an SG-list to .map_mr_sg() that is larger than what fits into a single MR. .map_mr_sg() must not attempt to map more SG-list elements than what fits into a single MR. Hence make sure that mlx5_ib_sg_to_klms() does not write outside the MR klms[] array. Fixes: b005d3164713 ("mlx5: Add arbitrary sg list support") Signed-off-by: Bart Van Assche Reviewed-by: Max Gurtovoy Cc: Sagi Grimberg Cc: Leon Romanovsky Cc: Israel Rukshin Cc: Acked-by: Leon Romanovsky Reviewed-by: Sagi Grimberg --- drivers/infiniband/hw/mlx5/mr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c index d9c6c0ea750b..99beacfc4716 100644 --- a/drivers/infiniband/hw/mlx5/mr.c +++ b/drivers/infiniband/hw/mlx5/mr.c @@ -1777,7 +1777,7 @@ mlx5_ib_sg_to_klms(struct mlx5_ib_mr *mr, mr->ndescs = sg_nents; for_each_sg(sgl, sg, sg_nents, i) { - if (unlikely(i > mr->max_descs)) + if (unlikely(i >= mr->max_descs)) break; klms[i].va = cpu_to_be64(sg_dma_address(sg) + sg_offset); klms[i].bcount = cpu_to_be32(sg_dma_len(sg) - sg_offset);