Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8411643rwb; Tue, 13 Dec 2022 06:09:07 -0800 (PST) X-Google-Smtp-Source: AA0mqf4sMq6QN7ZmhwC/uf8+D/qqsnAo2Etpy4em23hOeiBk8LYGwokXK1QtmESV2/MaZNHjnqt+ X-Received: by 2002:a17:903:258d:b0:189:89e2:5406 with SMTP id jb13-20020a170903258d00b0018989e25406mr20473939plb.24.1670940547609; Tue, 13 Dec 2022 06:09:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670940547; cv=none; d=google.com; s=arc-20160816; b=X0nmnU7sGbe6MXisg7TLeMIEMp4q8XM0kOpubJxs+9883FuSWY0setcxYnCxZJNRF2 VOZQbPVPszcAJJ4+byyRB7+ozf+5C9iIe88ydlOSE1xaz9WtjMj/hMQENp0TmHLLgJBB aVI+SkFpVR/y7UOCLsbfx/LstLiy4FALbdKuAQwk4RnnMb8+HzYy8y2/Lkbio7i1Vrj3 ehXlVotD1w8ooerwj/0OQVyvVVI17/k4/Rgn17eeDMPfN0sC/UFVnSnPX5Gxk1ayy/CF kHiDjFxIk3PUDYxby18Zntqscd3xPIGaybM2V38nu42YNgj2lJ6rERLHd7odhuaQwpX9 bggQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=XrZbGC6xqJZQMHq1bEwiY8nPFiDOlrB2h9CcFtTYOII=; b=YnHr2qP3GkM5QjF1+Yc59EmTDO5ngE1uKyB5QBo7VnLMLN0aLOZtQoixoyqvV/I0wB W88bia7ym6c9bpWSoABwszxCQ/JMEA92X0AIFHLzcWpTNJwsDpKMuL9CW9+edM6WBuI8 Ljba75FF0Vdj6sNQqxsG43kUZEkQQVieyORmtdQftRlpTKTtKoUi9ajkzRKkNiT+JiOT gyMXzBvU4qnoW60yCLcp70LiWvFPScxK3FnDgr2kIoh7nX0CLaKauycQ0dIOVf9ujKlv fEAq/zhB5fzdysSz2qMMvzIj3jU2WF7pzhFCKTcrEQrkAxNyT4Zmf3l/T/+G3Mcn4CBD BI8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=HcapBWXG; 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 e18-20020a17090301d200b00189380323f7si13812739plh.318.2022.12.13.06.08.57; Tue, 13 Dec 2022 06:09:07 -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=HcapBWXG; 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 S235747AbiLMNmp (ORCPT + 72 others); Tue, 13 Dec 2022 08:42:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235729AbiLMNmm (ORCPT ); Tue, 13 Dec 2022 08:42:42 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69820319; Tue, 13 Dec 2022 05:42:41 -0800 (PST) Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BD9wGqY029177; Tue, 13 Dec 2022 13:42:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=qcppdkim1; bh=XrZbGC6xqJZQMHq1bEwiY8nPFiDOlrB2h9CcFtTYOII=; b=HcapBWXGRcRfMx9l8rqhgvf2tEqCizXpYUygFV4ISpKlE/DgkY+L8ygKJDHEXZB4srii XdN8yavL8065nysa9M0M20Qg3jmtg9VMbO3+j3aIOerWedyHCGCL8IhC8MHLeEntD3la IO0q/2l8li9jC0BQBf+0+FjlTK1HE6S0DS+a7zIbxExnixtwF4kQY8nF/f3UygO7Ef1u ++4/4T2vYqoaZoswivzDnFMj6tf2HARx8u5QHLXnSzMpx48tpfRmWHJze5Daqe+4A2Mw lFMUit/kufyt4rPN2CvggF3R+yYzdqaHwukBpIGwwhhRV0Gohwfq6PO6jawJOes+J3hN bA== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3meq7qgqbg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Dec 2022 13:42:37 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 2BDDgb41022791 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Dec 2022 13:42:37 GMT Received: from [10.216.62.137] (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, 13 Dec 2022 05:42:31 -0800 Message-ID: <367fdcef-7360-055a-897b-71a66063b4ba@quicinc.com> Date: Tue, 13 Dec 2022 19:12:10 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH] spmi: Add check for remove callback in spmi_drv_remove API Content-Language: en-US To: Greg KH CC: , , , , , , , , , , , , References: <1670145780-13111-1-git-send-email-quic_jprakash@quicinc.com> <1670145780-13111-2-git-send-email-quic_jprakash@quicinc.com> From: Jishnu Prakash In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) 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: R7W2dDGa3t7pIn16aSIt_MUAB9o0Zs_L X-Proofpoint-ORIG-GUID: R7W2dDGa3t7pIn16aSIt_MUAB9o0Zs_L 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-13_03,2022-12-13_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 phishscore=0 lowpriorityscore=0 spamscore=0 mlxlogscore=677 suspectscore=0 adultscore=0 priorityscore=1501 clxscore=1015 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212130122 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,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 Hi Greg These are two SPMI drivers without remove callbacks defined: drivers/mfd/qcom-spmi-pmic.c drivers/mfd/hi6421-spmi-pmic.c We made this change after noticing an issue internally with the first one above, there was a crash when trying to remove it with rmmod, which is fixed by this change. In addition, since the probe of the QCOM SPMI PMIC driver uses devm_ functions throughout, we could see that with this change, when we remove the device with rmmod, the cleanup does happen correctly even though there is no remove function defined in the driver. The last function called in the probe of our SPMI PMIC driver is devm_of_platform_populate(), to probe all the PMIC peripheral drivers under this one, and when this driver module was removed with rmmod, we could see that the individual PMIC drivers under it also got depopulated with their remove APIs getting called. If it is possible for a SPMI driver to be removed correctly by rmmod without having a remove API defined, this change should be right, what do you think? Thanks, Jishnu On 12/13/2022 5:34 PM, Greg KH wrote: > On Sun, Dec 04, 2022 at 02:53:00PM +0530, Jishnu Prakash wrote: >> Add a check for remove callback presence before calling it for a >> spmi driver, to avoid NULL pointer dereference error if remove callback >> has not been specified for that SPMI driver. >> >> Signed-off-by: Jishnu Prakash >> --- >> drivers/spmi/spmi.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/spmi/spmi.c b/drivers/spmi/spmi.c >> index a456ce5..6b34356 100644 >> --- a/drivers/spmi/spmi.c >> +++ b/drivers/spmi/spmi.c >> @@ -350,7 +350,8 @@ static void spmi_drv_remove(struct device *dev) >> const struct spmi_driver *sdrv = to_spmi_driver(dev->driver); >> >> pm_runtime_get_sync(dev); >> - sdrv->remove(to_spmi_device(dev)); >> + if (sdrv->remove) >> + sdrv->remove(to_spmi_device(dev)); >> pm_runtime_put_noidle(dev); >> >> pm_runtime_disable(dev); > > What in-kernel spmi driver does not have a remove function set that > requires this change? > > thanks, > > greg k-h