Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp3643109pxy; Tue, 4 May 2021 06:58:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxWgjXx8Cy8DPi1qVsCIqfJuXHj5rEYWUT8lnz7D9LEHmIrwg5scnbk1Q4CJ3KCX+S+Y23 X-Received: by 2002:a05:6402:708:: with SMTP id w8mr26047622edx.49.1620136701211; Tue, 04 May 2021 06:58:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1620136701; cv=pass; d=google.com; s=arc-20160816; b=pndH4AhqPc9iMXgoB9CgKtg2NdGcchDgOtDyKiSH8HBRFn/xE7Exm2T+KnnluxnSc3 ETZ5rS1GbTrF9RmuqdlSFLxrllsGKSVjMuXOkXGPaWr0RzEtRIWaCrnOnTZGyShJjTBF e6B017DMo2wPdmCKMW8I6+nSOmEFT3QYtd02xlbMkTnhwJLdDDsb4ecv61uPQfxgQVlK Lyj+Btf6labaBdBz8WnYfCkqEtg55vfk3AgFE8VGsMoyRLV1nrhOsl1qK8rrfvAjuM36 Q+MuoIlXeedh/ZS+iKJPdfMROW+87DQB8RLr/41yCboU66x/nrDIJIfwuEa/w+KmuFnx m07A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:in-reply-to:user-agent:date:message-id:from :references:cc:to:subject:dkim-signature; bh=Ydj7RaCj08K9ZGUu0dRRejcz68JdBKzwu+z5xfgillw=; b=kEDsM9EY5IyoMIjFdkw4E7fXdP3U+QGf5dRMfe5g+Kr73NfJfP9iXY9qP3+a/XKvse wO7b+zRs7NGiEVt0Kk1jvVrTzw+6n1/SVvdEYRX8JlJXjpu9J3rXBHou1Q3KsrkqZeOi o4tw01qp5eprIlTj3tUOwKvucHdvdwxGe/qO56UXav/PXUXgWVqN5lD0NqL93AOIdqkQ 4y1mtYTe+HoEw1BmZA7WCueF2/Q1lsdwoEnZqBuKZYOEwc+PlMvDQaas6Ksi9XZnUTd0 TIwTa9HAcC9MnkQHrtnkPeR7T6GVlXlRvT+CSmo/b/8FrS2QDBdNuWB88bZJ506ReZPz VhZQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mysnt.onmicrosoft.com header.s=selector2-mysnt-onmicrosoft-com header.b=kdKz8IX6; arc=pass (i=1 spf=pass spfdomain=kontron.de dkim=pass dkdomain=kontron.de dmarc=pass fromdomain=kontron.de); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q6si2776119ejn.673.2021.05.04.06.57.57; Tue, 04 May 2021 06:58:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mysnt.onmicrosoft.com header.s=selector2-mysnt-onmicrosoft-com header.b=kdKz8IX6; arc=pass (i=1 spf=pass spfdomain=kontron.de dkim=pass dkdomain=kontron.de dmarc=pass fromdomain=kontron.de); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231340AbhEDNzA (ORCPT + 99 others); Tue, 4 May 2021 09:55:00 -0400 Received: from mail-eopbgr70090.outbound.protection.outlook.com ([40.107.7.90]:8941 "EHLO EUR04-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231216AbhEDNy7 (ORCPT ); Tue, 4 May 2021 09:54:59 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZD3Ti22EGK3jpR8nFkk/XPROy6HtHRaZYRN9tPpn3vwcKACbeKBQMHtnMXJW//esA1X0bOlzQrlbGTIa7+pKZH9mDS1BlLvid54t/viGv9Z8pxRqMcGIpx3q4s1PvD/QeVJktdY/cHL19UdIfcLLqUdKJxd9KpQZwXStY48I/b4vgBOJJXuvGV4TjqxZFpcm3YzuI8soj7bbm6ygt7d4rP8/cUqhkkWVO6eDwQdz3CMVJ/rkA5KSl0f2nwxNsDvyGTTt5hj81VR+bApe+LXbubnxeB56/bv8ISIeYLdynMgxHKbLefxYO2eE/Ucibe63370hEQXZz8sptkWVBcBP7A== 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-SenderADCheck; bh=Ydj7RaCj08K9ZGUu0dRRejcz68JdBKzwu+z5xfgillw=; b=A25DOZ6GYpTcLeZEud4LG6TPCTqAvtaQAfYY/FkY2mXE+deUc2KTyelCqBHp9PKWym5lT7OTmufm/BgAiZHcJBvqdiBev67Rw5s6JTIMajp+iIbBrfXMC4jr7pri3rkYM7sq+EEcUe9xDZPBO6YxtgHMFhJDlEf43TPm/v+/gMX9YCAaifz67IGS4HJ6RmrQLEzYli02sWH5o/7xLQyV8l+VeTMGp6dXA9HrHMLH7RL12HX6lKjoeyC+l1fr/nLGeaTJ0sVIeISzumPY1kHdv9Cf8Ac9CthQS+o8v9Jet0O27S3NiKor/y10Jzz4Uwc2FwTNkWGS91OB9K/kVWMUDA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=kontron.de; dmarc=pass action=none header.from=kontron.de; dkim=pass header.d=kontron.de; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mysnt.onmicrosoft.com; s=selector2-mysnt-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ydj7RaCj08K9ZGUu0dRRejcz68JdBKzwu+z5xfgillw=; b=kdKz8IX6UOIJOc9oO5CQ68G+OPNTVi01yoVyRFXWm0EVoHmLGGpr/GPnp4f8DbTsO4h6gwD5AmM/12NjlqeEkZpJJR4HaGFiL36dVbNxwZNjyNhgetIpOPNwF6lah5OSBpCxed5sGmApoAPxgtzimwnQSGA0oVBSVYELx4/mytg= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=kontron.de; Received: from AM0PR10MB2963.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:157::14) by AM8PR10MB3985.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:1e2::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.35; Tue, 4 May 2021 13:54:02 +0000 Received: from AM0PR10MB2963.EURPRD10.PROD.OUTLOOK.COM ([fe80::3d8a:f56b:3a0c:8a87]) by AM0PR10MB2963.EURPRD10.PROD.OUTLOOK.COM ([fe80::3d8a:f56b:3a0c:8a87%7]) with mapi id 15.20.4087.044; Tue, 4 May 2021 13:54:02 +0000 Subject: Re: Null pointer dereference in mcp251x driver when resuming from sleep To: Andy Shevchenko , =?UTF-8?Q?Timo_Schl=c3=bc=c3=9fler?= , Marc Kleine-Budde Cc: linux-can@vger.kernel.org, Wolfgang Grandegger , "David S. Miller" , Jakub Kicinski , Liam Girdwood , Mark Brown , Vincent Mailhol , Oliver Hartkopp , Tim Harvey , netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: From: Frieder Schrempf Message-ID: <66f07d90-e459-325c-8d5d-9f255a0d8c8f@kontron.de> Date: Tue, 4 May 2021 15:54:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [89.244.177.213] X-ClientProxiedBy: AM3PR05CA0139.eurprd05.prod.outlook.com (2603:10a6:207:3::17) To AM0PR10MB2963.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:157::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.10.27] (89.244.177.213) by AM3PR05CA0139.eurprd05.prod.outlook.com (2603:10a6:207:3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.27 via Frontend Transport; Tue, 4 May 2021 13:54:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8e579b66-6c64-454d-2b8d-08d90f0412e6 X-MS-TrafficTypeDiagnostic: AM8PR10MB3985: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bIx5HpcfXPVrO1y0Y17YmhmRsr1CQCniXI+HRdkALaSQ4S5d0dqUM2BTcvLpep5bxZ5Z8LdIUK6w34QppztmQB0mgTjh1O6yANIjWP9/y3h42OGYIbHlf2Rhtp0GOCJiF8IeceGdy0/Y/daBGGRAUV2Y+5DLq8hfiF3gVAeycjmsce8PqxLfE7+R91/Lw6Srnv5+uHx1tMHvv06dcv6CxDYtxm4Unci5PlXWVJ4Tjritem7C1hum0hQ9QxlTuFvakg2ZdnSErrACbUWbdb5nnNE+XMw+qdL5KRQ7Q8ZdMfP9hDGbyIfz+WBkA/uF7cQQf7KoTEbLQxiAv6t+hOiC3sjBc7ThmwzsAep923RlUsRX10W5EeXdbJiAbkWVyN/PtjvN5tYXZoeRV8yGUTmcl0aItuiaiZHZxolIftWbefNrlThJRKkFBPLiJDjjmrD69zWERs7scJXSPEqoG+exnyQqRZwsiLwq6k4Pgwzr6KuRoq/QGs62Q0dKgNOEDFrP9fNODL+iDmAV81wyjDM1lpPYGtAEvVzBwhnC+vz4mJyu6fdC3t913k+T6JqZMJGQwI3Hghp1pFtX5koo0tKdo06ljAsfWTtB6bHB0xW3WREBYDOucE2MnwZGRzimQs4ToffYBF8/qyRlfrUMXfSQgqjQl9A8sdgjhEMM8VUGqKNquU3Q9HchNTxyGgcfrp4I X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR10MB2963.EURPRD10.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(4636009)(346002)(366004)(39860400002)(136003)(396003)(376002)(66556008)(66476007)(8676002)(66946007)(31686004)(6486002)(53546011)(83380400001)(44832011)(2616005)(110136005)(16526019)(4326008)(16576012)(7416002)(478600001)(2906002)(956004)(54906003)(26005)(36756003)(186003)(38100700002)(316002)(5660300002)(31696002)(8936002)(86362001)(43740500002)(45980500001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?RlRHMVpteGtzKzZDZFdBMzlDWE1YSFd5aFc3MDMyUDRIaHdRUHdiUmN3cjk5?= =?utf-8?B?YThMNGZIUit4SVFGbllvd2hiZGdpM1duMTFOQ3lRbkVGek9jTlRJVzhpN2Nz?= =?utf-8?B?WjFJdDJoVkVKRHR0dFBEWnVBUStKeHh0aVV3UXErdndtS01EQnlWS2VlK0Fs?= =?utf-8?B?TjErOFRLZ2JTR3FWaDhWUjRydjc1L1oxTkUzQlZ4NzNkbFlzbWpIeUorbHRC?= =?utf-8?B?WG1qQnR4a29OS0JRVmR4b3I5dlVKMEtvU1p1bHNxMTZ3eFAzRnNBbk5RNzRW?= =?utf-8?B?MVZRZzdoeU9oTDdoNlBKcU81R3FSLzFrSWJGajBDc1R0LzFQUFc1bWZsYUhF?= =?utf-8?B?WkltbnpGbTZNSnpXN1BNUWJKb21Rd3NiWnhVRlVHeVBuR21BSHorRXNjMWZL?= =?utf-8?B?MnpHWEJPOGo5WWlTUTRWVkxHcmJUVmE3OXArempZa0IxdTFnVVhQTGhrMlRS?= =?utf-8?B?Q0NoZzBraDRDUzh5NnQwM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2M1THplbG9WbUNTSUErSVN4aEoyUk1rSWY3WGNxMm1zNE5O?= =?utf-8?B?VmtYMDM5UzBZb3NyMHZzWEc3NGlIQmFQb1RSSThuSW5qYmI5RnBOUVZPRDVY?= =?utf-8?B?QzZubmtmMytiNUpJM2w0SmRhRXEvYmJCaXhOSzdOVjlMRXJWei9DWi95VVZW?= =?utf-8?B?YVdwSU1XY3JybXdLSFByZWxtbVIzb1dseUVmZXJEOWc2WWFRMitrc0EyNkda?= =?utf-8?B?Q1BSQ2hiV09EWDlocXY2ZHA0YW5XQ2c2ZC9RYnlvM1J4UEtpZVgwa1pKaXRw?= =?utf-8?B?dTZacldwa3BMSndpdHJpZG5EYnNhd2FPWW5Zc3RNS0F5V3dOQXVPNEtaZXV3?= =?utf-8?Q?pkHFcu9m2wBuHQYl5bNrKTBk8d6G/z9E1ILHiF9?= X-OriginatorOrg: kontron.de X-MS-Exchange-CrossTenant-Network-Message-Id: 8e579b66-6c64-454d-2b8d-08d90f0412e6 X-MS-Exchange-CrossTenant-AuthSource: AM0PR10MB2963.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2021 13:54:02.4104 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8c9d3c97-3fd9-41c8-a2b1-646f3942daf1 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: B/CICNW6oUdwE4F9sXIkqXXCe3isgWDr5V/opdpVubW0wxriFmKAvzjDY6Cm7P7U0/GD4xAZlGBwJFXvxYfAc8bhhIyBft9+cUacqWb/Rhs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR10MB3985 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03.05.21 15:54, Andy Shevchenko wrote: > On Mon, May 03, 2021 at 04:48:10PM +0300, Andy Shevchenko wrote: >> On Mon, May 03, 2021 at 04:44:24PM +0300, Andy Shevchenko wrote: >>> On Mon, May 03, 2021 at 03:11:40PM +0200, Frieder Schrempf wrote: >>>> Hi, >>>> >>>> with kernel 5.10.x and 5.12.x I'm getting a null pointer dereference >>>> exception from the mcp251x driver when I resume from sleep (see trace >>>> below). >>>> >>>> As far as I can tell this was working fine with 5.4. As I currently don't >>>> have the time to do further debugging/bisecting, for now I want to at least >>>> report this here. >>>> >>>> Maybe there is someone around who could already give a wild guess for what >>>> might cause this just by looking at the trace/code!? >>> >>> Does revert of c7299fea6769 ("spi: Fix spi device unregister flow") help? >> >> Other than that, bisecting will take not more than 3-4 iterations only: >> % git log --oneline v5.4..v5.10.34 -- drivers/net/can/spi/mcp251x.c >> 3292c4fc9ce2 can: mcp251x: fix support for half duplex SPI host controllers >> e0e25001d088 can: mcp251x: add support for half duplex controllers >> 74fa565b63dc can: mcp251x: Use readx_poll_timeout() helper >> 2d52dabbef60 can: mcp251x: add GPIO support >> cfc24a0aa7a1 can: mcp251x: sort include files alphabetically >> df561f6688fe treewide: Use fallthrough pseudo-keyword > >> 8ce8c0abcba3 can: mcp251x: only reset hardware as required > > And only smoking gun by analyzing the code is the above. So, for the first I > would simply check before that commit and immediately after (15-30 minutes of > work). (I would do it myself if I had a hardware at hand...) Thanks for pointing that out. Indeed when I revert this commit it works fine again. When I look at the change I see that queue_work(priv->wq, &priv->restart_work) is called in two cases, when the interface is brought up after resume and now also when the device is only powered up after resume but the interface stays down. The latter is a problem if the device was never brought up before, as the workqueue is only allocated and initialized in mcp251x_open(). To me it looks like a proper fix would be to just move the workqueue init to the probe function to make sure it is available when resuming even if the interface was never up before. I will try this and send a patch if it looks good.