From patchwork Sun Dec 4 09:23:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jishnu Prakash X-Patchwork-Id: 13063811 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 72653C3A5A7 for ; Sun, 4 Dec 2022 09:23:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229928AbiLDJXl (ORCPT ); Sun, 4 Dec 2022 04:23:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbiLDJXi (ORCPT ); Sun, 4 Dec 2022 04:23:38 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D51016580; Sun, 4 Dec 2022 01:23:37 -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 2B49Jb9a016480; Sun, 4 Dec 2022 09:23:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=wnv+eALC//9uYoKqfbEwGHq0ODkglh3YfZ+e98rMwq8=; b=I2hS3oSbE38opmZZILkujUsh1g0xHtZNXxwqvqB2Pn/tIG8YH1Em1DtpPdfGAYpPVkOJ ediEk2yRZ5o4vazay8w93ee65nfU9EuGxP2+Jjjt7zgUKEzbNCKNU4/TNOReWX5xtiJ6 uGdiSsYWjpkT/g9qfSED7U3cGeM3Wo7GXu3DR2Psl+6GGL2lWtTMelivUJ1BBCiuE/lg +u/Mm1ABcvscHC3dMqo/5wXZsYkJvQi9BLEdt5PC0AFihDww8kakUxvyde0aw7/fudtH vgjYw2uCq7WbjGWLJjIvGw44cBtIuRt56KcQekbVKXJ4/5eK0mQk7njpASd8qLIJv9eP ZA== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3m7wdxswaw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 04 Dec 2022 09:23:34 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 2B49NVBc008193 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 4 Dec 2022 09:23:31 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; Sun, 4 Dec 2022 01:23:27 -0800 From: Jishnu Prakash To: , , , , , , , , , , CC: , , Jishnu Prakash Subject: [PATCH] spmi: Add check for remove callback in spmi_drv_remove API Date: Sun, 4 Dec 2022 14:53:00 +0530 Message-ID: <1670145780-13111-2-git-send-email-quic_jprakash@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1670145780-13111-1-git-send-email-quic_jprakash@quicinc.com> References: <1670145780-13111-1-git-send-email-quic_jprakash@quicinc.com> MIME-Version: 1.0 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: -F2_Jhz04IL-8gvOGyiHMgVpjPYQ--st X-Proofpoint-ORIG-GUID: -F2_Jhz04IL-8gvOGyiHMgVpjPYQ--st 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-04_05,2022-12-01_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 impostorscore=0 clxscore=1015 adultscore=0 mlxscore=0 phishscore=0 spamscore=0 priorityscore=1501 malwarescore=0 suspectscore=0 lowpriorityscore=0 mlxlogscore=771 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212040087 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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);