From patchwork Sun Oct 15 12:37:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Auhagen X-Patchwork-Id: 13422200 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FE2033C5 for ; Sun, 15 Oct 2023 12:37:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=voleatech.de header.i=@voleatech.de header.b="ZQnN25/X" Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2101.outbound.protection.outlook.com [40.107.20.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E93A7A9 for ; Sun, 15 Oct 2023 05:37:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k2E2JWgfaHVt/I3K8lZbf0UmVTtW3OQ9bzncw4L2fx/bTBvbJDn3U1mRl/CUppLMSvqFRUCzY9fDPT9wuFj89rkUaOdvUaRfoweSREFGaiVSdRtxGTJQtvAohL9cJsERrUtRkR566OM/vIURwejbHNaj3+7Ba1K0hSajKOJeMLKWn8I2mEXJnIm8Egkb5zXhIM7+58Wk84R4BeiL3G++XJY5N9jycbLCDruAP2sYyB08H03qhqF86qUEdPdvDyXbZ9QJy+XTQGeUgRbjYPThgmCr+LENlUOJC1/BUOZhDWBEj8M0w0g7XB6gD32onp9HiGvWFNHKdy8ILSxcHgr85w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VhNo5kCMAnhjKFvCYnwAh5t0U18szkdazU5fwIPNvIs=; b=hDF6wD7WAkKf8JqPODklqlh7/PDogNv561hEWl2TBQaoK6RGz1TtcnxRVaH9cVL7yxfY6epdYcIkUkwvLIu1BNbBG6E8Rr3ohn0Hu2Kis0JCbadXKpkwmdaJzpAEXTVS94d3bX0meiavJ5WpcqtTmu8pZwHDI7X9KYeMteqT8ZHtQxZflx0T7vgSAUciqWzaDLLdzmwsKkl908kaOnlqzFz6NBG/nrVc/BqPvLDEN+qNzqqxnruqV0m+1RMzG3nNxLoLNwx2cJRWkrTDCZr8oZcdNliLMRt+ETWr4miG1EUoF41qA9PLDcEnGd7xakWIJnzhSeXm6g9yrlEXdBcGsQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=voleatech.de; dmarc=pass action=none header.from=voleatech.de; dkim=pass header.d=voleatech.de; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=voleatech.de; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VhNo5kCMAnhjKFvCYnwAh5t0U18szkdazU5fwIPNvIs=; b=ZQnN25/XXamaNQiWRosHkQ3fodqpGsJcJnIZk/LHfJjXmkfqch7uINOxq+7VcJwhVYhgH8BbH2ujg5jtukOcrOtyHNOTQdc8ihugxYRoVF6SYksJ7UknoWJpxMkJlvykTI4cWdqpRWeq2EIIEoO//GeWKez14TBP6Pp6R9CvFI4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=voleatech.de; Received: from AM9PR05MB8857.eurprd05.prod.outlook.com (2603:10a6:20b:438::20) by DB9PR05MB8123.eurprd05.prod.outlook.com (2603:10a6:10:23e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.47; Sun, 15 Oct 2023 12:37:31 +0000 Received: from AM9PR05MB8857.eurprd05.prod.outlook.com ([fe80::cd64:d5c9:2116:1837]) by AM9PR05MB8857.eurprd05.prod.outlook.com ([fe80::cd64:d5c9:2116:1837%7]) with mapi id 15.20.6863.047; Sun, 15 Oct 2023 12:37:31 +0000 Date: Sun, 15 Oct 2023 14:37:27 +0200 From: Sven Auhagen To: netdev@vger.kernel.org Cc: thomas.petazzoni@bootlin.com, brouer@redhat.com, lorenzo@kernel.org, Paulo.DaSilva@kyberna.com, ilias.apalodimas@linaro.org, mcroce@microsoft.com Subject: [PATCH v3 1/2] net: page_pool: check page pool ethtool stats Message-ID: Content-Disposition: inline X-ClientProxiedBy: FR0P281CA0087.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1e::12) To AM9PR05MB8857.eurprd05.prod.outlook.com (2603:10a6:20b:438::20) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR05MB8857:EE_|DB9PR05MB8123:EE_ X-MS-Office365-Filtering-Correlation-Id: 8b0c750f-f0be-4430-c73b-08dbcd7b7f92 X-MS-Exchange-AtpMessageProperties: SA X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GfocrzJSRj9XjucJlufLdSz/eJxoUT/XUr48POu86PDRB69U+2bTSOiEtUGGB8iN52wdrGWjLfX/YmdNPwxR1YH0Wu56OlP+oL/OnWtBGLpNfllWQ0agQx1/AxrxeoyFLN4OuEvw6oku1InyRX7EACIJ2KdOGkHuXGD76q0Mu9QTOsUayGmpa0ZwGR/cunRLGhC6iRSem4F3vCRqRmYVBbKtSX/bV5Nh/2soN4OPPuYtTcJ+z8QlkK77erqznAM/op0OSPOMyX+dOvpRbXJnKZL57GY7XmksJMJ06dPYfPKke9Pm2DyvE6xtn5kOM9Qsvlv9hEUqyNIDR4Od7LxKsUWvzhIIM9CeLOIRX5BU9A8+RiMW9hcrgCiPKxNgYldW9oDrjpy4eg6j58Df5GmaRPo/8HIhGksZTqu5vXLhSj3+FPf0/o8v2LplL/yjUzqT5WLOYEFyG04GgErfRlzVfYoLO3WiOdu9qTPadKCJXGPqMgHmQmXDBKJJuXeKDZC1FKOaymM97ZItVRDub4/7B58HXOOAUOw3KFyln0H3IJsSDOQN+yziguvn+LyCSY/l X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR05MB8857.eurprd05.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(7916004)(346002)(366004)(39830400003)(136003)(376002)(396003)(64100799003)(1800799009)(451199024)(186009)(6666004)(9686003)(6512007)(6506007)(5660300002)(8936002)(8676002)(4326008)(6486002)(478600001)(26005)(6916009)(316002)(41300700001)(66946007)(66556008)(66476007)(86362001)(38100700002)(4744005)(33716001)(2906002)(44832011);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +iqFLObmwyg6XdY6t61tgJOCIvGgRFlIrgN+V8exdy9+kSPdg32wUDb5hf0NKWIiMeMGGcOIcWAguS2D22VPHgcn0Rn+PvqYxyYzKRGtKuYbOJYxkaP5Ll9zi8Cx+L0zE8YAliIF3DELMzXF0YWAdVQGuY1wWKw20pjjS6n8z7aeqZSa7mYqho+bP7Y/z5JJ1OJhaHR0rPREWcCCd9micWLGGYIHL9i9x2CJvX0RY6G6V4yU5b6UxvNvIwXJ4iJnt+C4rw6wKUgT3XVeRdx6j3xRs0XYIdGuPrwmlizIBrP0CBQpzCndBVAd4MiRxSmmuf+lqdqPzHf1zrQYyKwqAtpkEJqamFO/3jIssEFwxqei95bpjmoQTrGID66DP6rldjrorneyxPz57JGk4VAF2DrMHFbPN8jk7mx1qgI2naY2J+/wBrNH6yttrJPMjcsiNDheaDIlh+1dKIpd25Tjjqq4+Nkv0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qsazN9CgtksLIQL3fvnyLhmjBsVcA34QmsHbtoZuZzb7M/2wTCA== X-OriginatorOrg: voleatech.de X-MS-Exchange-CrossTenant-Network-Message-Id: 8b0c750f-f0be-4430-c73b-08dbcd7b7f92 X-MS-Exchange-CrossTenant-AuthSource: AM9PR05MB8857.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2023 12:37:30.9426 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b82a99f6-7981-4a72-9534-4d35298f847b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: aFxVXOC4ixnOalxf3A15nf7FIAIR+0u+mUg6wtngxwchaj1GMO1Q7TSIcRMy2fP6cbHOF5Zxo8C9JlusBYnl2cV/boI96K1S3+ydo16dEks= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR05MB8123 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org If the page_pool variable is null while passing it to the page_pool_get_stats function we receive a kernel error. Check if the page_pool variable is at least valid. Signed-off-by: Sven Auhagen Reported-by: Paulo Da Silva --- net/core/page_pool.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/core/page_pool.c b/net/core/page_pool.c index 2396c99bedea..4c5dca6b4a16 100644 --- a/net/core/page_pool.c +++ b/net/core/page_pool.c @@ -65,6 +65,9 @@ bool page_pool_get_stats(struct page_pool *pool, if (!stats) return false; + if (!pool) + return false; + /* The caller is responsible to initialize stats. */ stats->alloc_stats.fast += pool->alloc_stats.fast; stats->alloc_stats.slow += pool->alloc_stats.slow; From patchwork Sun Oct 15 12:37:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Auhagen X-Patchwork-Id: 13422201 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D70BA6D19 for ; Sun, 15 Oct 2023 12:37:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=voleatech.de header.i=@voleatech.de header.b="JAYBjXgR" Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2117.outbound.protection.outlook.com [40.107.104.117]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AC16DC for ; Sun, 15 Oct 2023 05:37:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OgBl5D2a6uT+B/4756x4XWJf4YdjuhCnu3n/A6YwJOWhuuwVH7ZXl+EPH+0yFjr2sWjzAEipYrKycD5aD5XSLTQUh9faQ0azim5jJgEKfTYb6I1Yr5b99gSx5txu/oaH0ICjPVJ0WZQ+KsF30bIU9Rk89U8OPM4wCU4ka9b4FTEzvet+JBLQWIdLtM9oIY2q7sKhzQqUC2mCnpR7wzdaOsdqtjCDcZemJgif3TcCIWsgRyVzWGqs5G1GYwaePQGN5hS2+GrQ6Go/Rm1lBn6nBEIQMqRVoXTLyo1b6Hnd457Kv9+IXY9QLswAbodBIU1lZy2NDirgFJEI5HC11RDzdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8PT0EaqOb7ceInDfF1kSh3qzMIjQHAbBp2PxZmzHAiQ=; b=W+r6ZO6+7o0M6Jg/C8gUZ+Lt+hPM0pLafWKrSSuddDFS5H5VsfFcB5jUuW2/6VU2//ibTKZIuVQAaR+CJisvCQjEqKkBgicvFoGAcP/bXSq1aCQmH9HD6M11WDLesSrbCOsKjcD5T1owZymVxipdUIV1DcF1CHHpaKBPizKAti47pwoNP2XHccSiqHVEZSYK0e7dlyDcJFoqtlnB4mM7wjLApNgI3qQl/i48cDtiEsDPGXyCkfxUbcsRV1D+nvEcuSC2BY0FJvBqlm1ZhhIja32uZlOSV3VmFLllNNy9IK1EnmLa+alZI7a/Np1NZ29VLUqIUbfikdyln/7l0ns1AQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=voleatech.de; dmarc=pass action=none header.from=voleatech.de; dkim=pass header.d=voleatech.de; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=voleatech.de; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8PT0EaqOb7ceInDfF1kSh3qzMIjQHAbBp2PxZmzHAiQ=; b=JAYBjXgRQ/VJhOd4dK4zpne+62mGwgFrTVK63VeO48M5+lx9VqQ0/+A9JjRXTFSn7CFQqqVSFP3kSqhudYohgzYKhOnP+PM2XW+bxUGDxJRt4sB6SaTHcQUVMm9umL/tGeYSnx7/kfWk3gLhwJim0Np9yb8MxHRuwQiWDuvm148= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=voleatech.de; Received: from AM9PR05MB8857.eurprd05.prod.outlook.com (2603:10a6:20b:438::20) by DB9PR05MB8123.eurprd05.prod.outlook.com (2603:10a6:10:23e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.47; Sun, 15 Oct 2023 12:37:54 +0000 Received: from AM9PR05MB8857.eurprd05.prod.outlook.com ([fe80::cd64:d5c9:2116:1837]) by AM9PR05MB8857.eurprd05.prod.outlook.com ([fe80::cd64:d5c9:2116:1837%7]) with mapi id 15.20.6863.047; Sun, 15 Oct 2023 12:37:54 +0000 Date: Sun, 15 Oct 2023 14:37:50 +0200 From: Sven Auhagen To: netdev@vger.kernel.org Cc: thomas.petazzoni@bootlin.com, brouer@redhat.com, lorenzo@kernel.org, Paulo.DaSilva@kyberna.com, ilias.apalodimas@linaro.org, mcroce@microsoft.com Subject: [PATCH v3 2/2] net: mvneta: fix calls to page_pool_get_stats Message-ID: <5kcf3pxkzor5p4lvzfgbszthrl33fzho6qonyvznxrjdde4gci@vt2nakbgdpfq> Content-Disposition: inline X-ClientProxiedBy: FR3P281CA0041.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4a::17) To AM9PR05MB8857.eurprd05.prod.outlook.com (2603:10a6:20b:438::20) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR05MB8857:EE_|DB9PR05MB8123:EE_ X-MS-Office365-Filtering-Correlation-Id: 7bd18618-ba93-4c5a-4926-08dbcd7b8d4d X-MS-Exchange-AtpMessageProperties: SA X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3XcBW1F3G2EmUsvGPsUzJYNjo8DCvzH4wpEx+6ceVKt5it5w0GytGKx262VQ76mfOFZew1IMMKsujxS46W2asECYDFKvHVuQcjk2itg/3ptzB2ApFDuppy0GF8Q92ymG8mXvkm2D6q0R+6GbljO0BD7pMOLAUWT2vGqRB7F0XpZamsqpybGCDQpHndPuoIF9g9MDU4qUpijQbeV5WE19iDMM0Mm5qRfJnVx/vv/bSCXvy3Qodp/0STP5pxp9H2k0Q/YYXdmFiUTIwk9q2scc9G9GKSJOGeC/YPAT2smBNCR4aXASOjm4j3rDbe6N+NlIw6zhopA/1HEOW9+budFG2k7wvWqWpH64uvI8SW7KXN9jByyJVtoX1AJ06W6VBCAP7gHRignHc8fDCSSwLIt+RRH8TiCfGqHL1w26wtzJQTm12YrBZ18qZyUcPqnGm8+uwYrdtVChrgsX2LjrlvrmzpyHRSyas2tNyzxsJJiujd1zl4BCeVRKpeV3KYidScIHlHt+/rwQap7/Vq2m+p5wKfMFHytFYH/PguYmZ7UW2G2Egrh5spjGVf2l8iygrTty X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR05MB8857.eurprd05.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(7916004)(346002)(366004)(39830400003)(136003)(376002)(396003)(64100799003)(1800799009)(451199024)(186009)(6666004)(9686003)(6512007)(6506007)(5660300002)(8936002)(8676002)(4326008)(6486002)(478600001)(83380400001)(26005)(6916009)(316002)(41300700001)(66946007)(66556008)(66476007)(86362001)(38100700002)(33716001)(2906002)(44832011);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GQMQ+XAJuNXNdreF3PbjE1PpN9okKqTD6Dc5NMEeyll+kiTZLcFgifSzJUw86wtH0vTcZXItddSJfEEE33GHpdZefoFPB9JJ6pMpcMi78mCCznoVFcIW95Nrt6W1TIkXQuRzfUl8V+egoqt0VX2Qz8enak3QjVTw4Hb9u1W3RKKB1XacgtK54vyCz9kwc2tWjTjc1oTpDkMcbhFuvGhoa1HNDLD4NyjrfaYbIPJhYTtdn/MHuQwzrdyPvqaonixGA0KFBLwjDPd3yzyRPbBZLtczJ+wtwhhEsuLPzcYRmxS2HwTzh5i5M0Z7RSmL4FijYNCCskrL5ualHIAxwEwd44PRtLBRk0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QYRkVMbFFrJXe0GMcIN8CtUWUIyHbexqKMHW2jPesqvk28fY4oAevKLMtKaKeViHUL7IcnqfNPoq+sMoMUeCxU6RWyX/h+wRT5tSvEWc3F3bBBm1FH1oEggDojrzAmrE5pVULxq8WfptcyQrlwJ+jMjVQ8t/HIeGyR7YxqUTRoloqsozRcG8bejHQQK/wT5lMz0TYg== X-OriginatorOrg: voleatech.de X-MS-Exchange-CrossTenant-Network-Message-Id: 7bd18618-ba93-4c5a-4926-08dbcd7b8d4d X-MS-Exchange-CrossTenant-AuthSource: AM9PR05MB8857.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2023 12:37:53.9487 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b82a99f6-7981-4a72-9534-4d35298f847b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: QhO6CY9L72JkGub7emouteqCgrp5I0PD2U8Oeobkm/ZqFdTB9MgsgNuvq5sTPTKo9J/DF8HzU6WEPz+KfTw/ggBrXoII8kzqdKqjHsdOhQs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR05MB8123 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Calling page_pool_get_stats in the mvneta driver without checks leads to kernel crashes. First the page pool is only available if the bm is not used. The page pool is also not allocated when the port is stopped. It can also be not allocated in case of errors. The current implementation leads to the following crash calling ethstats on a port that is down or when calling it at the wrong moment: ble to handle kernel NULL pointer dereference at virtual address 00000070 [00000070] *pgd=00000000 Internal error: Oops: 5 [#1] SMP ARM Hardware name: Marvell Armada 380/385 (Device Tree) PC is at page_pool_get_stats+0x18/0x1cc LR is at mvneta_ethtool_get_stats+0xa0/0xe0 [mvneta] pc : [] lr : [] psr: a0000013 sp : f1439d48 ip : f1439dc0 fp : 0000001d r10: 00000100 r9 : c4816b80 r8 : f0d75150 r7 : bf0b400c r6 : c238f000 r5 : 00000000 r4 : f1439d68 r3 : c2091040 r2 : ffffffd8 r1 : f1439d68 r0 : 00000000 Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none Control: 10c5387d Table: 066b004a DAC: 00000051 Register r0 information: NULL pointer Register r1 information: 2-page vmalloc region starting at 0xf1438000 allocated at kernel_clone+0x9c/0x390 Register r2 information: non-paged memory Register r3 information: slab kmalloc-2k start c2091000 pointer offset 64 size 2048 Register r4 information: 2-page vmalloc region starting at 0xf1438000 allocated at kernel_clone+0x9c/0x390 Register r5 information: NULL pointer Register r6 information: slab kmalloc-cg-4k start c238f000 pointer offset 0 size 4096 Register r7 information: 15-page vmalloc region starting at 0xbf0a8000 allocated at load_module+0xa30/0x219c Register r8 information: 1-page vmalloc region starting at 0xf0d75000 allocated at ethtool_get_stats+0x138/0x208 Register r9 information: slab task_struct start c4816b80 pointer offset 0 Register r10 information: non-paged memory Register r11 information: non-paged memory Register r12 information: 2-page vmalloc region starting at 0xf1438000 allocated at kernel_clone+0x9c/0x390 Process snmpd (pid: 733, stack limit = 0x38de3a88) Stack: (0xf1439d48 to 0xf143a000) 9d40: 000000c0 00000001 c238f000 bf0b400c f0d75150 c4816b80 9d60: 00000100 bf0a98d8 00000000 00000000 00000000 00000000 00000000 00000000 9d80: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 9da0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 9dc0: 00000dc0 5335509c 00000035 c238f000 bf0b2214 01067f50 f0d75000 c0b9b9c8 9de0: 0000001d 00000035 c2212094 5335509c c4816b80 c238f000 c5ad6e00 01067f50 9e00: c1b0be80 c4816b80 00014813 c0b9d7f0 00000000 00000000 0000001d 0000001d 9e20: 00000000 00001200 00000000 00000000 c216ed90 c73943b8 00000000 00000000 9e40: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 9e60: 00000000 c0ad9034 00000000 00000000 00000000 00000000 00000000 00000000 9e80: 00000000 00000000 00000000 5335509c c1b0be80 f1439ee4 00008946 c1b0be80 9ea0: 01067f50 f1439ee3 00000000 00000046 b6d77ae0 c0b383f0 00008946 becc83e8 9ec0: c1b0be80 00000051 0000000b c68ca480 c7172d00 c0ad8ff0 f1439ee3 cf600e40 9ee0: 01600e40 32687465 00000000 00000000 00000000 01067f50 00000000 00000000 9f00: 00000000 5335509c 00008946 00008946 00000000 c68ca480 becc83e8 c05e2de0 9f20: f1439fb0 c03002f0 00000006 5ac3c35a c4816b80 00000006 b6d77ae0 c030caf0 9f40: c4817350 00000014 f1439e1c 0000000c 00000000 00000051 01000000 00000014 9f60: 00003fec f1439edc 00000001 c0372abc b6d77ae0 c0372abc cf600e40 5335509c 9f80: c21e6800 01015c9c 0000000b 00008946 00000036 c03002f0 c4816b80 00000036 9fa0: b6d77ae0 c03000c0 01015c9c 0000000b 0000000b 00008946 becc83e8 00000000 9fc0: 01015c9c 0000000b 00008946 00000036 00000035 010678a0 b6d797ec b6d77ae0 9fe0: b6dbf738 becc838c b6d186d7 b6baa858 40000030 0000000b 00000000 00000000 page_pool_get_stats from mvneta_ethtool_get_stats+0xa0/0xe0 [mvneta] mvneta_ethtool_get_stats [mvneta] from ethtool_get_stats+0x154/0x208 ethtool_get_stats from dev_ethtool+0xf48/0x2480 dev_ethtool from dev_ioctl+0x538/0x63c dev_ioctl from sock_ioctl+0x49c/0x53c sock_ioctl from sys_ioctl+0x134/0xbd8 sys_ioctl from ret_fast_syscall+0x0/0x1c Exception stack(0xf1439fa8 to 0xf1439ff0) 9fa0: 01015c9c 0000000b 0000000b 00008946 becc83e8 00000000 9fc0: 01015c9c 0000000b 00008946 00000036 00000035 010678a0 b6d797ec b6d77ae0 9fe0: b6dbf738 becc838c b6d186d7 b6baa858 Code: e28dd004 e1a05000 e2514000 0a00006a (e5902070) This commit adds the proper checks before calling page_pool_get_stats. Fixes: b3fc79225f05 ("net: mvneta: add support for page_pool_get_stats") Signed-off-by: Sven Auhagen Reported-by: Paulo Da Silva --- drivers/net/ethernet/marvell/mvneta.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c index 8b0f12a0e0f2..f368bcef725a 100644 --- a/drivers/net/ethernet/marvell/mvneta.c +++ b/drivers/net/ethernet/marvell/mvneta.c @@ -4734,13 +4734,16 @@ static void mvneta_ethtool_get_strings(struct net_device *netdev, u32 sset, { if (sset == ETH_SS_STATS) { int i; + struct mvneta_port *pp = netdev_priv(netdev); for (i = 0; i < ARRAY_SIZE(mvneta_statistics); i++) memcpy(data + i * ETH_GSTRING_LEN, mvneta_statistics[i].name, ETH_GSTRING_LEN); - data += ETH_GSTRING_LEN * ARRAY_SIZE(mvneta_statistics); - page_pool_ethtool_stats_get_strings(data); + if (!pp->bm_priv) { + data += ETH_GSTRING_LEN * ARRAY_SIZE(mvneta_statistics); + page_pool_ethtool_stats_get_strings(data); + } } } @@ -4875,14 +4878,21 @@ static void mvneta_ethtool_get_stats(struct net_device *dev, for (i = 0; i < ARRAY_SIZE(mvneta_statistics); i++) *data++ = pp->ethtool_stats[i]; - mvneta_ethtool_pp_stats(pp, data); + if (!pp->bm_priv && !pp->is_stopped) + mvneta_ethtool_pp_stats(pp, data); } static int mvneta_ethtool_get_sset_count(struct net_device *dev, int sset) { - if (sset == ETH_SS_STATS) - return ARRAY_SIZE(mvneta_statistics) + - page_pool_ethtool_stats_get_count(); + if (sset == ETH_SS_STATS) { + int count = ARRAY_SIZE(mvneta_statistics); + struct mvneta_port *pp = netdev_priv(dev); + + if (!pp->bm_priv) + count += page_pool_ethtool_stats_get_count(); + + return count; + } return -EOPNOTSUPP; }