Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp5167011rwj; Tue, 20 Dec 2022 21:57:12 -0800 (PST) X-Google-Smtp-Source: AMrXdXvpHhQVLiZFZMGytFpbMfO++4Ke9gU7epyiHUyhnwcwCQ88XZfZ98nN0pV2pl80WN2a2BlR X-Received: by 2002:a05:6a21:8697:b0:ad:5747:9f6e with SMTP id ox23-20020a056a21869700b000ad57479f6emr968500pzb.39.1671602232554; Tue, 20 Dec 2022 21:57:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671602232; cv=none; d=google.com; s=arc-20160816; b=un/NE6yu8P3MrMrgU7P7IGZcKayQAXmwOF3XeYsRJaTFAIFwgedEXYDu2Eh0CSt5SS 1f1Flsc7BB+YZU6cCtq2TsiaffZl3wma4UGRJssXi3KYXyeWBd9J7Xv0KICx8eYbiZfs 8KUtMZY7LrLvdwoaX4hIhl3m340NjMhsulDt15GHyrob21BMrVyEJDKqQ6RcKXYFVx+W XqLyQuJRqinTPCIFTrKft1WPc0bECWoOzIGIJlIYr/4UtEAI2FDXxgr4KJsTHfAz1biU IsAsP+Sqoq2PQzjun56TzI/pnNBwj7r1k+P+07uslvfGd8MH1naGzxp+zClxRJccX7fT HmnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=iuuCsVMes5uuYN5lfuNxmp9Zc6Nb3HtNYUdhownHy0U=; b=Dugnswr4oxTm2BH1tTlVf/U2m79ZBlMOHaPJ/f05iP/MyP4ql6zVaMX9W0OlOD6iT+ /xZP9+Yid20uoXrNgJ7vFLK08RUI3ZnT3k6wfCtvwVa8CHgvF/ZeW31EXRMVokALmyrA 4ebOBs/mpeJU4vp21m954DsDpSRvmzscEjsmq5QvBU32mYoojWULpaEGA3MDtes/spho apM/wTOyDtMGPA6w4CX0cQj98bmUeNyuR282EdAIn9UHAHzJohuao+Zd7CppymuH6Npp WatDzVknWEktoUaxxXX+rpuZn9ig+A4EkWfdidKcAf7CW3TPK4RyOoA6ZfsQghpgDpx9 N31A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Kn4gEh4Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x17-20020a633111000000b00476f59d84a6si17033010pgx.214.2022.12.20.21.57.03; Tue, 20 Dec 2022 21:57:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Kn4gEh4Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234274AbiLUFiA (ORCPT + 69 others); Wed, 21 Dec 2022 00:38:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229569AbiLUFh6 (ORCPT ); Wed, 21 Dec 2022 00:37:58 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 506151D33A; Tue, 20 Dec 2022 21:37:56 -0800 (PST) Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BL59XOf015301; Wed, 21 Dec 2022 05:37:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=qcppdkim1; bh=iuuCsVMes5uuYN5lfuNxmp9Zc6Nb3HtNYUdhownHy0U=; b=Kn4gEh4QtNZ9WeWNKAkW74Q1RKUniNUdgDFn9L+1XGhXr7a9S82STXa/V6zKJrjhcGpg 37jj7uJPwHsvhUD9sZfoKM3c4rI6WLaEmr20n+C0KFPYIcr/CI6+rXCt5bjPYTAL5g6e ao4k3fubo9IXraL3IKnnpQ1S8aGvgGnX8a6zSAHPYWRUgQ04JeP2zs/wQsqvJJYAI5r0 dLzn3zsS43xz5d631Wtrq1iHUOKTj/ym+wDkaHEPidAucNxhv/nCUidGQ4YUjNndjkWK w+kuM6D1lY0TQ3ZBdQSB0zTR/MIAgAp1t90Oc0XP7Fj7QMWOAfTo+913NqqUGFDGtkhx bg== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3mk195k81n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 21 Dec 2022 05:37:52 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 2BL5bp9H004136 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 21 Dec 2022 05:37:51 GMT Received: from jprakash-linux.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Tue, 20 Dec 2022 21:37:47 -0800 From: Jishnu Prakash To: , , , , , , , , CC: , , , Jishnu Prakash Subject: [PATCH] Add a check for remove callback in spmi driver removal API Date: Wed, 21 Dec 2022 11:07:11 +0530 Message-ID: <1671601032-18397-1-git-send-email-quic_jprakash@quicinc.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: H2MqB-7DbaoUmH9KXmg_xrHfvRJjD1I8 X-Proofpoint-ORIG-GUID: H2MqB-7DbaoUmH9KXmg_xrHfvRJjD1I8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-21_01,2022-12-20_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 spamscore=0 priorityscore=1501 mlxlogscore=244 mlxscore=0 impostorscore=0 lowpriorityscore=0 adultscore=0 bulkscore=0 malwarescore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212210038 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When removing a SPMI driver, there can be a crash due to NULL pointer dereference if it does not have a remove callback defined, as the remove callback gets called directly in spmi_drv_remove(). This is one such call trace observed when removing the QCOM SPMI PMIC driver: dump_backtrace.cfi_jt+0x0/0x8 dump_stack_lvl+0xd8/0x16c panic+0x188/0x498 __cfi_slowpath+0x0/0x214 __cfi_slowpath+0x1dc/0x214 spmi_drv_remove+0x16c/0x1e0 device_release_driver_internal+0x468/0x79c driver_detach+0x11c/0x1a0 bus_remove_driver+0xc4/0x124 driver_unregister+0x58/0x84 cleanup_module+0x1c/0xc24 [qcom_spmi_pmic] __do_sys_delete_module+0x3ec/0x53c __arm64_sys_delete_module+0x18/0x28 el0_svc_common+0xdc/0x294 el0_svc+0x38/0x9c el0_sync_handler+0x8c/0xf0 el0_sync+0x1b4/0x1c0 If a driver has all its resources allocated through devm_() APIs and does not need any other explicit cleanup, it would not require a remove callback to be defined. The SPMI framework also does not enforce the presence of a remove callback when a client driver registers with it. Hence, add a check for remove callback presence before calling it when removing a SPMI driver. Jishnu Prakash (1): spmi: Add a check for remove callback when removing a SPMI driver drivers/spmi/spmi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.7.4