Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp35773pxb; Wed, 30 Mar 2022 22:13:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtesPlN4J8HMJW2tYA7frDqvUQMqSKjRhs3Ex47L6vnibZmqzMRNtaEKCfpnV23pmz+BMG X-Received: by 2002:a05:6a00:15c6:b0:4fa:aaec:ef42 with SMTP id o6-20020a056a0015c600b004faaaecef42mr3567665pfu.74.1648703630259; Wed, 30 Mar 2022 22:13:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648703630; cv=none; d=google.com; s=arc-20160816; b=QE0t0+GPSPgDY32T+nxNkvaJ5KKhXuBweC8njP1txb5xQhVV961ev1662W8WWT+t+u V5l5mY7oerAg8zj0GSvkttBJjs2obkDMXb9sUKhKWtsnAMxoaMM/gwbWxMx3mPQZ5nlQ xek6juBtYzBjvI8Mbm5J1bkuZLBBO1Dp9zYhyuqElVIws8YrqC95RAlLP7JTh8ohzRAT Y+L4pDyTckusSJDhUS55ZlRNNuSQWtkx/gJUC2R3n+kw3/WDzz2TWti7/gGBOwrJnxdk IpjkM304pPOPZxDs0M1K7/iVwTb3dHBp+TE4YFxF/9atB9Rd8DaTkYzGTqsu7odjjo9V guXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:dlp-filter:cms-type :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature:dkim-filter; bh=atNiTbJQ5upQMrld2+SnKpbR/2YzyUNsEH8o2X9kkdI=; b=XQL1/HHf6dmup+JQ/J7S+LYFht8VZIjMX4u/J+R9k59f3XDhFv5f9i0A6mtkM9JHSD JT1uK38mZvfI4kyskES3nkn91LUH8BOBId8ZBDy/I8lSdroN7zRW8FDg/OpMmy1to4hy A9hpgt6FRgL6HxtY2YSYzU5EEdAJ65vGHI1ITt3zQW6A+9OIfJsaYhmZ5HFE3LrEKwPH 46XPJom/Saf8Ov+l6StMVgggyCSNW3YXER7GaWfEbh2WgsL6kcspDZedP8x3LIcfQVg1 X3KfBIs+mYVXFxpuox+x2nU6O9Sr4h3pt75NftTSnxLZnFGPcJIaXBQ6+rr1K55gpDMP K20g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="ufaKw/mo"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id i25-20020a635859000000b003816043f00dsi23868918pgm.514.2022.03.30.22.13.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 22:13:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="ufaKw/mo"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4A40E1C0249; Wed, 30 Mar 2022 21:15:14 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229587AbiCaEQw (ORCPT + 99 others); Thu, 31 Mar 2022 00:16:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230286AbiCaEQh (ORCPT ); Thu, 31 Mar 2022 00:16:37 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A3FB16BCED for ; Wed, 30 Mar 2022 21:00:39 -0700 (PDT) Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20220331030338epoutp04879dc79db3570243e37b008bc366f4ad~hWByXj3ow0472804728epoutp04c for ; Thu, 31 Mar 2022 03:03:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20220331030338epoutp04879dc79db3570243e37b008bc366f4ad~hWByXj3ow0472804728epoutp04c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1648695818; bh=atNiTbJQ5upQMrld2+SnKpbR/2YzyUNsEH8o2X9kkdI=; h=From:To:Cc:Subject:Date:References:From; b=ufaKw/moSs9+mixMGD/oFuSvGxYT4L2tlWGKQ7nhqy9sHytm3XctKw0g6Fc2bo+n0 Jkp8rVYI00tkntrZLTk9bkB0VAOf44eOkBx0E9hZYOp+NegJs1TlxyylShuIq8Vb5e Y0vuA9Jx3g5RqgsuZnm7CSLAI9JEnvBSZ7hZaYHE= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas1p2.samsung.com (KnoxPortal) with ESMTP id 20220331030338epcas1p2a49e06fe56daf7a2c2c5cf5808323b90~hWBx-LJzN2258122581epcas1p2i; Thu, 31 Mar 2022 03:03:38 +0000 (GMT) Received: from epsmges1p5.samsung.com (unknown [182.195.38.241]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4KTSmn1dMtz4x9QC; Thu, 31 Mar 2022 03:03:37 +0000 (GMT) Received: from epcas1p2.samsung.com ( [182.195.41.46]) by epsmges1p5.samsung.com (Symantec Messaging Gateway) with SMTP id 79.18.28648.90A15426; Thu, 31 Mar 2022 12:03:37 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas1p3.samsung.com (KnoxPortal) with ESMTPA id 20220331030336epcas1p3b8bf7b1841d4b246030b57b668312169~hWBw-A0Tw1494514945epcas1p3e; Thu, 31 Mar 2022 03:03:36 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220331030336epsmtrp22cb232d9a8967911c4e27a3551b9981c~hWBw_W5jy2738927389epsmtrp2I; Thu, 31 Mar 2022 03:03:36 +0000 (GMT) X-AuditID: b6c32a39-ff1ff70000006fe8-e1-62451a09818f Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 57.DE.24342.80A15426; Thu, 31 Mar 2022 12:03:36 +0900 (KST) Received: from VDBS1418.vd.sec.samsung.net (unknown [168.219.244.30]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220331030336epsmtip1b19966f0ede5198d937ae4fd8e29f34b~hWBw3h7N90211802118epsmtip1R; Thu, 31 Mar 2022 03:03:36 +0000 (GMT) From: bumwoo lee To: MyungJoo Ham , Chanwoo Choi , linux-kernel@vger.kernel.org Cc: bumwoo lee Subject: [PATCH] extcon: modify extcon device to be created after driver data is set Date: Thu, 31 Mar 2022 12:03:24 +0900 Message-Id: <20220331030324.42621-1-bw365.lee@samsung.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPKsWRmVeSWpSXmKPExsWy7bCmni6nlGuSwd8l3BYn1ixisrj+5Tmr xeVdc9gsbjeuYHNg8ejbsorR4/MmuQCmqGybjNTElNQihdS85PyUzLx0WyXv4HjneFMzA0Nd Q0sLcyWFvMTcVFslF58AXbfMHKBFSgpliTmlQKGAxOJiJX07m6L80pJUhYz84hJbpdSClJwC swK94sTc4tK8dL281BIrQwMDI1OgwoTsjO/nGtkKdglUPJy9hbWB8TNvFyMnh4SAicSG1fcY uxi5OIQEd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t7C2sD4 mbeLkYNDQsBE4s+ryi5GLg4hgd2MEnOmvmftYuQEiktKnF3+iB2iRlji8OFiiJofjBIPWj6z g9SwCWhIXLx4nRnEFhEolrhwYDELiM0soCbx50wPE4gtLBAisWTSBbAaFgFVicZ/H9hAbF4B K4m7i9ewQeySl+j+94cFIi4ocXLmE6g58hLNW2czT2Dkm4UkNQtJagEj0ypGydSC4tz03GLD AsO81HK94sTc4tK8dL3k/NxNjOAw09Lcwbh91Qe9Q4xMHIyHGCU4mJVEeD8edE4S4k1JrKxK LcqPLyrNSS0+xCjNwaIkznuh62S8kEB6YklqdmpqQWoRTJaJg1Oqgcn8i8CFvuvRpcE6nNf8 9q7VPfPBavrj7/mJjz3eX3deWO3o1Pb1mtJlg8cZXPwCp2dn7VRk453kdU/08uLo4NP7704s NnoovHji0xKjK5+OVXxvtOT0CGcPa++cGfbcpUVEfcPa5S8n3r4ctCfPvOZ249Ee6TT3fcH3 1O13vOps05zBtfANX8WN7FyDtwe3yJj+9/hluHDiNruU9tTS+9l7LI2sq/qlQ80eamtof7AJ 9Ah74WyV9+kg36f16+wizCKFFL+odZq/v6N/d8HvT1ppr+ZmbJzwge/ozZ0XH1UXCLMKLPQR /+MQbVuxn0O3r03g2CaGydEbt55e03ZUftoyi4Msokf2+K34xur54pASS3FGoqEWc1FxIgBv +6nbogIAAA== X-CMS-MailID: 20220331030336epcas1p3b8bf7b1841d4b246030b57b668312169 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220331030336epcas1p3b8bf7b1841d4b246030b57b668312169 References: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, someone can invoke the sysfs such as state_show() intermittently before set_drvdata() is done. And it can be a cause of kernel Oops because of edev is Null at that time. So modified the driver registration to after setting drviver data. - Oops's backtrace. Backtrace: [] (state_show) from [] (dev_attr_show) [] (dev_attr_show) from [] (sysfs_kf_seq_show) [] (sysfs_kf_seq_show) from [] (kernfs_seq_show) [] (kernfs_seq_show) from [] (seq_read) [] (seq_read) from [] (kernfs_fop_read) [] (kernfs_fop_read) from [] (__vfs_read) [] (__vfs_read) from [] (vfs_read) [] (vfs_read) from [] (ksys_read) [] (ksys_read) from [] (sys_read) [] (sys_read) from [] (__sys_trace_return) Signed-off-by: bumwoo lee --- drivers/extcon/extcon.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index d27cd9f88f86..74fee04bd764 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c @@ -1224,18 +1224,13 @@ int extcon_dev_register(struct extcon_dev *edev) edev->dev.type = &edev->extcon_dev_type; } - ret = device_register(&edev->dev); - if (ret) { - put_device(&edev->dev); - goto err_dev; - } + device_initialize(&edev->dev); spin_lock_init(&edev->lock); edev->nh = devm_kcalloc(&edev->dev, edev->max_supported, sizeof(*edev->nh), GFP_KERNEL); if (!edev->nh) { ret = -ENOMEM; - device_unregister(&edev->dev); goto err_dev; } @@ -1251,9 +1246,14 @@ int extcon_dev_register(struct extcon_dev *edev) list_add(&edev->entry, &extcon_dev_list); mutex_unlock(&extcon_dev_list_lock); + ret = device_add(&edev->dev); + if (ret) + goto err_dev; + return 0; err_dev: + put_device(&edev->dev); if (edev->max_supported) kfree(edev->extcon_dev_type.groups); err_alloc_groups: -- 2.32.0