Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754031AbcLNSPl (ORCPT ); Wed, 14 Dec 2016 13:15:41 -0500 Received: from mail-bl2nam02on0069.outbound.protection.outlook.com ([104.47.38.69]:34896 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752096AbcLNSPh (ORCPT ); Wed, 14 Dec 2016 13:15:37 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=David.Daney@cavium.com; Subject: Re: [v2] net:ethernet:cavium:octeon:octeon_mgmt: Handle return NULL error from devm_ioremap To: arvind Yadav , , , References: <1481732732-6892-1-git-send-email-arvind.yadav.cs@gmail.com> <3c3d5968-bc41-e1b7-6fda-78e92e7a9d56@caviumnetworks.com> <0be48286-2656-84b4-4cd8-93bea5fbc6f0@gmail.com> CC: , From: David Daney Message-ID: Date: Wed, 14 Dec 2016 10:14:54 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <0be48286-2656-84b4-4cd8-93bea5fbc6f0@gmail.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [50.233.148.156] X-ClientProxiedBy: BY2PR07CA0080.namprd07.prod.outlook.com (10.166.107.33) To CY1PR07MB2136.namprd07.prod.outlook.com (10.164.112.14) X-MS-Office365-Filtering-Correlation-Id: cca7149b-1fb1-4a9f-dc80-08d4244d1fb7 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CY1PR07MB2136; X-Microsoft-Exchange-Diagnostics: 1;CY1PR07MB2136;3:G2x4KnyGOVUBFU3KsZxq2uiFz3ifdGKYcVkzAoPuP7GzxzcHJKdgEuqcmvWS48GP70NDFZR4jIFUXect8O1hnwui09Sft0PAIbGpc4XAjKroJNv9PdXF+m9ifHiybRzdRl/zwNFA7F2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hVpiP0n5vjV1K03zf62/vvz0mFRhFafqhswEpNsnA5k5Sq3fHTXXz17v2uP5tPgZEnHAgU3Xf/T5L0WA3IxZQnNJngXJFXZMbdzuUdBevq5GnIRpTGcUmmpMfM+tq34j6yqpCuBwPxk5Wiyuom/or39iv/WdbUEnScxyb8fffsVrRGR1nbpteVTLUFw+mBY4loDuuXNJGfIn5nMJBIrIvFALY8MgoEK991aWvQhAX/PKLBnT6Qzxdsr15FePxdtU43oK/kAheNSXoZJNE0Ig7XbYutXv0UX7voc84id/r53kh42LpDRGg/FkvmKXVAtWH52kyCR+ASfbuayYp4WPa5riwMNzDKoJvusJc3dzAsyY4Bub3+uq5pyJm0nBpMQxRzQZFCnS5W5Lf8+ZtsGsFEpqOAUPsg25hbOqWX1jFog5Hvr7XYkdBQY= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6041248)(20161123560025)(20161123555025)(20161123562025)(20161123558021)(20161123564025)(6072148);SRVR:CY1PR07MB2136;BCL:0;PCL:0;RULEID:;SRVR:CY1PR07MB2136; X-Microsoft-Exchange-Diagnostics: 1;CY1PR07MB2136;4:G8VI4+6PHV/TSfL1Q+D9RhUJ719lvUjsKMcb15fMpfaKhtgtrZnUXmrTreFJPn/eLzfaVcVygc9qf1Ql5QPQXnvEoI29+0GUumjfDf1v8F+hkPbMLvKFhIGLFXJXmWd+nGTQNojbhoHEc5mJsYIbYUT2s9M5c5iXyOlW+l+XJcP3y2zHdLuXyR4VAU86cbkRnq2rYmqLNKxAJDqkrHBGwr0f9e5n1yE75qydioPAbzx+WubLiT28YaS9SWa4w2fZgTQ4drggC2A8iP4nLvPyB7lcNFoabq6noOaKtUVhs5z+77HjEAXC6bA2geuts/+Pme6Xv9nvwTs+g9k3SK+x8JqbZsWjHqHSzkbOr3Yd4rHzYfLCv5JSD5vWrJQ0H2hSR/coYX95xQiinHb580U4rDy7FEGZX1xjdlY3VWDywIENL1BFoknJJfyUG2lS+0kA/8d9FtS3H6bZZvLILHm116OzeownvgXqYFbgNwVSTbT+IiKdBhPgRwsG2b+ssZc1WHmWscXo58/4u1ejwad9QaG/wWdiifIc/dbKQ63smumrldwTMUTkN9dCZ4RASV90H2qL+oB61Z86iiyZtgYnHx4Hk4lFTpEJqucB+BacU8g= X-Forefront-PRVS: 01565FED4C X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(6069001)(7916002)(39450400003)(39840400002)(39410400002)(24454002)(199003)(189002)(54534003)(377454003)(66684002)(8676002)(6486002)(230700001)(6862003)(33646002)(76176999)(3846002)(69596002)(6116002)(65826007)(101416001)(106356001)(189998001)(68736007)(5660300001)(53416004)(66066001)(42186005)(54356999)(47776003)(97736004)(64126003)(50986999)(2906002)(5001770100001)(76506005)(65956001)(4326007)(31686004)(50466002)(65806001)(105586002)(83506001)(4001350100001)(42882006)(81156014)(36756003)(81166006)(6666003)(2201001)(6512006)(229853002)(23746002)(7736002)(38730400001)(92566002)(305945005)(39060400001)(8666005)(31696002)(2950100002)(6506006)(25786008)(7059030);DIR:OUT;SFP:1101;SCL:1;SRVR:CY1PR07MB2136;H:localhost.caveonetworks.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;CY1PR07MB2136;23:M1HJlL43rXznkRRVfB7gwwT3EBM2DTRwtazml?= =?Windows-1252?Q?eFUhsZIPedAcDqWV21UnSOSIsJpwKXSAFwXgs/I4ZMGi7QZGLREyUmIu?= =?Windows-1252?Q?QS6Nv6NrfAMwLXq+vygCzMmTmRmU+P/c5O7azJMoUhd1HCect+5fermc?= =?Windows-1252?Q?ivhzQGcR3oy6LgI+H9BsmGbD3yu5cWFgXcYz6CwE89jB86w5cHZvgnAx?= =?Windows-1252?Q?P5UEuw03JO+Cti+gjxsOt6Q5W/HXruXjxK6c2NLU3NrDMO5DKSuU3dwa?= =?Windows-1252?Q?PUR1CJPa9Qscb1LY7+AEYDqwdPo/WOVquWVs9FCLoKpfJ/qvDJpKBFpg?= =?Windows-1252?Q?zUSj6vK5fFAILIr/i8IyGlPTtejdlclATrR+7OEzAU2D/pNp9Te8k9gS?= =?Windows-1252?Q?rW/xJDXMIVIL2bueQ5ouEyCq1yBS827OW2G9nuomlNE5bjQOl/+oCIW1?= =?Windows-1252?Q?oxeKcbnzMIMWJZ/Nwx5Mo8Lgjh9DcmBXVJ0PyXioY/zAKdPqfQjgf6Ap?= =?Windows-1252?Q?+7M1iSoh9/TUNLaIRuhpQuI0VYOKi6GSCgscND/VwCgcpb6a7uuZ6Hq7?= =?Windows-1252?Q?I5UmtDtkWJQneK4hA83P/7IMbl6+3KsbGYj1svH1FzY9wJum+26q+hJn?= =?Windows-1252?Q?FUxUYjPvypC/cpUdHbftjbSTsyqOye5h8C2ASbLXVjwnaHboAh1Gqxx3?= =?Windows-1252?Q?kxGMH60YLnhCnPFegoDRo5J6SXs36dX9EtqLaUfcJ4ctNrtxXZsaWkUg?= =?Windows-1252?Q?WyxXf8zxcRCzLWhWbyn6gRjWBF/oN4huqoY/obStEU1xUn4UDDCQ5ebs?= =?Windows-1252?Q?uo9raimKqDxd48Wg+AdmHWGalTKvplCCCuDdnpvf+tpGn+8wcOAjyAsm?= =?Windows-1252?Q?LBgd9Ewh/hbf/hpdQrl9eLXa3DMAZdQBl7avlPP7wlHHhMpEar7nA4rX?= =?Windows-1252?Q?dif8qL7tHpRZOVAdIwXyRZ+DlucjiEqDMGhU1OJy/PnMQAQ+LBoOener?= =?Windows-1252?Q?0yV3KMQQoMz4MgletYS7m9wnA8vMhdiAQXE8t0s/gEjFOsM6PR0g/Qqb?= =?Windows-1252?Q?0r9wKW5HPSGQXe5KcU7AYmInyJ57dYK6yOR3+yUp2r4NRqbJj6xUDPCB?= =?Windows-1252?Q?Ne7F52Sw8bNpGg7iXWeqi4nHEewocWByS0VwKc05NIvuHXBdku+xN73X?= =?Windows-1252?Q?qoX67TkJx+0u4gHNCHJ4GfVNbqCcWbQbJhxdVoxaUdFs98esCM+K6v7U?= =?Windows-1252?Q?09X/xjQyPwgVJnlANV1Lh58bD/g26soce69dkznTY8CTyDKMvwhk4MLd?= =?Windows-1252?Q?avNF+f53qqoi889WfL4fA03xTsWKCDqueWtzi+JrVsKrOxRHR44HJkIU?= =?Windows-1252?Q?4m1m7kNMWyc+wUwZeBGk7g074n/09QnPFa8ZS9t0OFQNF9EhjQ0VHOkc?= =?Windows-1252?Q?kpBiOMNLSLozsH4fu8jLXVeZ4Z1kaAtOvtLtGP4IwOOt/Or8V+8lEfgS?= =?Windows-1252?Q?XOuPLZ3trkF5/Qc0K6ffEW8KrnCFtkUvKPxZEi0AwthcbyWq1BhJJhcR?= =?Windows-1252?Q?eWjm+LIDsr9onwMIQTDdCOnAOigQ+4lxhwSz0uMsOXr2Y/pjClOllwp6?= =?Windows-1252?Q?z+6XErAivS0E64sfvqR5Cdn/NjsR/2DyhByTbe0J0De4nA2crfce3Gf8?= =?Windows-1252?Q?Y8cvy+jyYYd0xnFU5FupPL/YhBTLOfDszVpwzbkY2ocXMjHziKV?= X-Microsoft-Exchange-Diagnostics: 1;CY1PR07MB2136;6:vmU+geFgz2ZKVPQCqi62kOiD7n91J5ZzToxOHzD5loqTbC0wtVhgpRnxZd/4iPBEfq7Ngx9rVDDGzXA4ls7bxelx4ePlL5dDUx27LwKCKZfIlRb1Ll/w4uk8Ms0sBCS2Nco74FmviKlkgMi6vm3VYN0CfFdP9fzUHPA/JexVEKWxX4RCblD8C2MIx15Q7yNWOFpPLRakj1D1fjOf1Mo8JMWvFXcO/ng2YKqMxyac1SGS45IBvsba+YFVEWt/ofqlDb+H68+60efttQ7x7hqdiXNURtbp1KBnLyGiZbD/aHctDCnC1PkE687LSAoWkQs+qva1DyY19wWsmrvneagU0gyS/HxIflW0ZpGAI/ht8ZdTfxlsTVX557fWGKNvKlNfb0ip/94DtEk3T1TcAfTB2YRI4A2+sjSUnKvCqy9jSeg=;5:zlIEhjxIJUVQTZeBWJJUy45Px/ZA2WG2mFLHI5zjPC14hhaBMjSLzjh7T0ur2hFaWWDHXs5XSgbS6sBneFpRrd8RwvDgBNlodaUGoaVJz+OiQokFFVhpKVqaJ6pvBJ/3uj+719Ihy1OsdbJkNBBzqw==;24:N0sD2/lPpPK+1et0ZkBRUnrYqhGXCfQHUXGuHNxnCObfsipnQvB9ZvhiYyHv8D3RjVa9sfoBZEtLUlD5SuiRWN9seXuBv5ysZqN0fKEHGlg= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CY1PR07MB2136;7:6svU4gykKQCwnr8jXA+Xlfja6TjnxxhvPrJK8cOW7a3cXFWm2TYf95xIlG/lD2tMbItbSPCYAXoGVQXFxhsdclcNf6oyeDnaFXkOCPYdLHBmsU/6JmBon95IA6x1PnzgM4d5AuAp/IWOz1R92oQVj05CR3t2qQVCWe4Rog8hr9QIKbcJF6HdZfB1GPP3q9ZQNFCvLxaM0O6xBPUUF+4KSxnYmwwpYKjYI5HAW526+3ct0DXaJLfeuibBd7f35GXBE4CAKzZvnVD+/WZwDvI/Ux1goS1aBT4YgSv1aaU1yazMl+2vX1vPSmNBr+naQMVrr5jqPNIEOzanZzL3294ZmiCi2JssLmh8TnBpQ7W85Ma1H1gVB0+r6q2ttZxAlCgzchalJCFcGxhpVybNLSVqfnHun+h1qK9cdKCpuo9sUmkAn8bsbyMbuT2XJvpnKfUre0U+sUi4S1NsoonLoy6Lyw== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2016 18:15:02.6645 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2136 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2652 Lines: 77 On 12/14/2016 10:06 AM, arvind Yadav wrote: > Yes, I have seen this error. We have a device with very less memory. > Basically it's OMAP2 board. We have to port Android L on this. > It's has 3.10 kernel version. In this device, we were getting Page > allocation failure. This makes absolutely no sense to me. OCTEON is a mips64 SoC with a ton of memory where ioremap can never fail, and it doesn't run Android, and you are talking about OMAP2. Q1: Have you observed a failure on the device for which you are modifying the driver? Q2: Have you tested the patch on hardware that uses the driver you are modifying by running network traffic through the Ethernet interface this driver controls? If you cannot answer yes to both of those questions, then you should probably note in the changelog that the patch is untested. David. > Vmalloc size was not enough to run all application. So we have decide to > increase vmalloc reserve space. once we increases Vmalloc space. > We start getting ioremap falilure. Kernel is getting NULL-pointer > dereference error. > > Here, It's just check to avoid any kernel crash because of ioremap failure. > We can keep this check to avoid this kind of scenario. > > Thanks > -Arvind > > > On Wednesday 14 December 2016 11:02 PM, David Daney wrote: >> On 12/14/2016 08:25 AM, Arvind Yadav wrote: >>> Here, If devm_ioremap will fail. It will return NULL. >>> Kernel can run into a NULL-pointer dereference. >>> This error check will avoid NULL pointer dereference. >>> >> i >> Have you ever seen this failure in the wild? >> >> How was the patch tested? >> >> Thanks, >> David Daney >> >> >>> Signed-off-by: Arvind Yadav >>> --- >>> drivers/net/ethernet/cavium/octeon/octeon_mgmt.c | 6 ++++++ >>> 1 file changed, 6 insertions(+) >>> >>> diff --git a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c >>> b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c >>> index 4ab404f..33c2fec 100644 >>> --- a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c >>> +++ b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c >>> @@ -1479,6 +1479,12 @@ static int octeon_mgmt_probe(struct >>> platform_device *pdev) >>> p->agl = (u64)devm_ioremap(&pdev->dev, p->agl_phys, p->agl_size); >>> p->agl_prt_ctl = (u64)devm_ioremap(&pdev->dev, p->agl_prt_ctl_phys, >>> p->agl_prt_ctl_size); >>> + if (!p->mix || !p->agl || !p->agl_prt_ctl) { >>> + dev_err(&pdev->dev, "failed to map I/O memory\n"); >>> + result = -ENOMEM; >>> + goto err; >>> + } >>> + >>> spin_lock_init(&p->lock); >>> >>> skb_queue_head_init(&p->tx_list); >>> >> >