From patchwork Mon Mar 7 13:37:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurentiu Palcu X-Patchwork-Id: 549082 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C6D5C433EF for ; Mon, 7 Mar 2022 13:38:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242902AbiCGNjZ (ORCPT ); Mon, 7 Mar 2022 08:39:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235124AbiCGNjX (ORCPT ); Mon, 7 Mar 2022 08:39:23 -0500 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2053.outbound.protection.outlook.com [40.107.20.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 508702F020; Mon, 7 Mar 2022 05:38:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PQn/Wo0FWTrJ8Ky11rCcQ6GS1yYQ18AxAwb6nnb5AGJpVqWrxP1svZN4vdeqj1N41Lt9zxQUz5TXPIBBPOqO3Jl9D1unEZx3LUocaNKHqIPoIAormxzdNEh+BQVsfqJbqhbswS6ZtByFXmFNHNCWF6SKkm7FD5z2vcau0qHGE5L/Ld6xXtqEuvE+qiHK9ovNi5kU4vlnFDhKy1tKuXpK34m3G6ntmcfYAicpddqGjO//NghP42VxO9D71qh+Cq1n+vhwtT5tLv5/pf0ezcv23/3lX0UIRtcbzLc0l2+UkCGYiwTDR16mHy1Ys5BvYqr1PY0JG8bWq9C97PuKyQt4zQ== 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=oS5+HYf9sklJH/I6BBHREnos1ynYhWuUKYDqXhj8TYI=; b=Z7yOnrhw4RYlqzLouwR3PytAJofo5IzH0S++0+zk5g8/3ntXX3yLhPjzgg56W4msR/jjCBp/BreIteEx2ucwflbeTNWz0ELM12gg/HdB2q9z8Xreya4r7Ms8YzwXc9ryp3ds6yw8iHeNPyAAfkeewO18cBAcVxzPN6YGR7+C+bhwVUYvvJQElkVOILRocvDKU+ytCNpZJulupqIPplhC5KPzx6L2FxKH9wfz3+gqdR8TiUtb2q7YIxGOHTVGK0dA2jvZzo5pPpoXbCzvBFqWXdSkffNteqvKO6bziDlOPZpw6ynwWo9Q9tMPJDR+7llujJAK6XqCQF4ImaNR+T7cYQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oS5+HYf9sklJH/I6BBHREnos1ynYhWuUKYDqXhj8TYI=; b=CppAmLEorp9GOl1U3gAPVP8fpGJk5E1p8ZnBb0FB/QJOoYD8evb1cgUj24KjoTDtA/FMhXnt6xseJv21fLQBoZ3MVEwWuE1/7LeFxcYM3zYZlo+GrOvTmjzAb8UqvOdYd2zmLHuytqqfMAtvOjabj+jkeOub6pL6PYapCaDoMOs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR0402MB3902.eurprd04.prod.outlook.com (2603:10a6:803:22::27) by AM9PR04MB8828.eurprd04.prod.outlook.com (2603:10a6:20b:40b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Mon, 7 Mar 2022 13:38:25 +0000 Received: from VI1PR0402MB3902.eurprd04.prod.outlook.com ([fe80::7075:9a92:d8b1:61cf]) by VI1PR0402MB3902.eurprd04.prod.outlook.com ([fe80::7075:9a92:d8b1:61cf%3]) with mapi id 15.20.5038.026; Mon, 7 Mar 2022 13:38:25 +0000 From: Laurentiu Palcu To: Jacopo Mondi , Kieran Bingham , Laurent Pinchart , =?utf-8?q?Nik?= =?utf-8?q?las_S=C3=B6derlund?= , Mauro Carvalho Chehab Cc: Laurentiu Palcu , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] media: i2c: max9286: fix kernel oops when removing module Date: Mon, 7 Mar 2022 15:37:50 +0200 Message-Id: <20220307133750.29708-1-laurentiu.palcu@oss.nxp.com> X-Mailer: git-send-email 2.17.1 X-ClientProxiedBy: AM0PR04CA0097.eurprd04.prod.outlook.com (2603:10a6:208:be::38) To VI1PR0402MB3902.eurprd04.prod.outlook.com (2603:10a6:803:22::27) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bf93bb45-da84-4bfd-13cd-08da003fc0ed X-MS-TrafficTypeDiagnostic: AM9PR04MB8828:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OMlQskFH/HUc9vzTcdc5pk6lWXsnMDyhSBiEuxSpMUeY59CD+YLNwOSeZPXrm3bWoF3vNdOqxWt2ITpZ8lz1pJcrhx+bXyKtUR9WVjcZxdnCjIAVcH4DerZsjY7sMPpLSbZTZv/PUQiSaAo8WrHuyy8JWnQemYl05a4NuJkhE1StuHOOtqf2nSMP1OKxyDqVJyG1ZC2lj5gZvR3hyflQk3QbMBu6IS+vIAApipJ7UcAeCllekTY5jiWGt0bmiqmrCgVZGTLelStEcykKIsPtCoHb2Hm6KiA347trMBUT2oxlwrOgquiV/kPwv0atpcF+6JzIbp1+0PvK9K3CWWnu9tI7rqBcWPo5RR5VCNcb6bds2LuQXIlgvHb0EZy5HiO6A4UIgZCu8VICK4A9SthKQpKcipoGdim1t3H5obluQ5emhvo5NLzkuE3SFqKzFRM0D6pFAHet8DpSj0VToctciqrsSnJQsz/xoW3LdEyF555P4f9NYeWHNjPQy+7wOQ+s5V3eZUXBnxeKuOuNuteL5wk7p4zl96KL++GjpUKPUQLRkEMA71xQHzQq9P96AxbvjDKIIcqLCGoXdn3KkxhuZ7XeaNhOxZhL9e/8Qz+VwGmZyaTL+VNwAagUy6+cu2erLXJLL4hgvZKMUbQtXb2pNRaG6x1k5hsQ5ixeOc5LJ/u8oc/3CipVnJ5XlctnTBXKrtihdOemxU2JVonnz8vpVQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR0402MB3902.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(2906002)(186003)(26005)(498600001)(66556008)(2616005)(1076003)(44832011)(4326008)(8936002)(66946007)(83380400001)(86362001)(66476007)(8676002)(45080400002)(52116002)(6666004)(6512007)(6506007)(6486002)(110136005)(38350700002)(38100700002)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OpK4vcghtGIyXU4JO1VBLAdh+2OUYOIl2NGnV9aduZlQYOEEvcc6t+lzVesZnp376IzfwR7qe+52UtwVp2hr6g1X4wVKGfm/lfteA8oJylCkjUlvvzBvkyRDedDGqkYIbum8lw5HCbdKRZydhtsXg8/v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oSurwvKxULDSL3agN7W1XrzwQGKDrQQjhdbZMAw3yiu2EId7cIEk0mHn1UVHxI+sIRUsJepiJcVcpRvbWLgJwmbMxoz2WNvUd1ZdgP9HHx/lhxj43CAqsyRpfzUobT1hj1hDjWE1cnYOUsWt9mZ2UQWXczk0ZqgYeto9MdY/hZa/OLUoQMMDNN3KvLUK6Izj34vlMP2pl560WFw90mRPk0VzK+7Ek0DDvo6HcYCeyWDO5foNAF85swCT1wPSK06XBBxDM5FJZ8eokmZm45lXWpGOWJ7dmARWPy5qdUEKKXUKIV8uOPkw0hrPcsq65tRhYKmbGu28KHbJsjnK7eYq3gMkp54VYbopX+SroVsmQNTaFGkiJET58w77dy6nYMyjJ37vxQNWiOmcHuYiLl6eXza28= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: bf93bb45-da84-4bfd-13cd-08da003fc0ed X-MS-Exchange-CrossTenant-AuthSource: VI1PR0402MB3902.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2022 13:38:24.9017 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: RbHiKQBbSQ5YD6FpaAVwN5E0jR0DtBR7JU4JBcYWS9Qwsh3d6PDfYILpNYI7McbSqDGIzXvkROjNGgR4KZT/ag== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8828 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org When removing the max9286 module we get a kernel oops: Unable to handle kernel paging request at virtual address 000000aa00000094 Mem abort info: ESR = 0x96000004 EC = 0x25: DABT (current EL), IL = 32 bits SET = 0, FnV = 0 EA = 0, S1PTW = 0 FSC = 0x04: level 0 translation fault Data abort info: ISV = 0, ISS = 0x00000004 CM = 0, WnR = 0 user pgtable: 4k pages, 48-bit VAs, pgdp=0000000880d85000 [000000aa00000094] pgd=0000000000000000, p4d=0000000000000000 Internal error: Oops: 96000004 [#1] PREEMPT SMP Modules linked in: fsl_jr_uio caam_jr rng_core libdes caamkeyblob_desc caamhash_desc caamalg_desc crypto_engine max9271 authenc crct10dif_ce mxc_jpeg_encdec CPU: 2 PID: 713 Comm: rmmod Tainted: G C 5.15.5-00057-gaebcd29c8ed7-dirty #5 Hardware name: Freescale i.MX8QXP MEK (DT) pstate: 80000005 (Nzcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : i2c_mux_del_adapters+0x24/0xf0 lr : max9286_remove+0x28/0xd0 [max9286] sp : ffff800013a9bbf0 x29: ffff800013a9bbf0 x28: ffff00080b6da940 x27: 0000000000000000 x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000000 x23: ffff000801a5b970 x22: ffff0008048b0890 x21: ffff800009297000 x20: ffff0008048b0f70 x19: 000000aa00000064 x18: 0000000000000000 x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000 x14: 0000000000000014 x13: 0000000000000000 x12: ffff000802da49e8 x11: ffff000802051918 x10: ffff000802da4920 x9 : ffff000800030098 x8 : 0101010101010101 x7 : 7f7f7f7f7f7f7f7f x6 : fefefeff6364626d x5 : 8080808000000000 x4 : 0000000000000000 x3 : 0000000000000000 x2 : ffffffffffffffff x1 : ffff00080b6da940 x0 : 0000000000000000 Call trace: i2c_mux_del_adapters+0x24/0xf0 max9286_remove+0x28/0xd0 [max9286] i2c_device_remove+0x40/0x110 __device_release_driver+0x188/0x234 driver_detach+0xc4/0x150 bus_remove_driver+0x60/0xe0 driver_unregister+0x34/0x64 i2c_del_driver+0x58/0xa0 max9286_i2c_driver_exit+0x1c/0x490 [max9286] __arm64_sys_delete_module+0x194/0x260 invoke_syscall+0x48/0x114 el0_svc_common.constprop.0+0xd4/0xfc do_el0_svc+0x2c/0x94 el0_svc+0x28/0x80 el0t_64_sync_handler+0xa8/0x130 el0t_64_sync+0x1a0/0x1a4 The Oops happens because the I2C client data does not point to max9286_priv anymore but to v4l2_subdev. The change happened in max9286_init() which calls v4l2_i2c_subdev_init() later on... Signed-off-by: Laurentiu Palcu --- drivers/media/i2c/max9286.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c index d2a4915ed9f7..04f5b7e3a9e5 100644 --- a/drivers/media/i2c/max9286.c +++ b/drivers/media/i2c/max9286.c @@ -1385,7 +1385,7 @@ static int max9286_probe(struct i2c_client *client) static int max9286_remove(struct i2c_client *client) { - struct max9286_priv *priv = i2c_get_clientdata(client); + struct max9286_priv *priv = sd_to_max9286(i2c_get_clientdata(client)); i2c_mux_del_adapters(priv->mux);