From patchwork Thu Nov 18 12:39:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olivier Moysan X-Patchwork-Id: 12693039 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0ED0C433EF for ; Thu, 18 Nov 2021 12:43:02 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A136D61A88 for ; Thu, 18 Nov 2021 12:43:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A136D61A88 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=foss.st.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=dvywrQYVRkdUSa7Gk1FCOsm5iri+jNuGYOy0AP25KaY=; b=Jv4q+7oLtP0CJy I/Og3ns5z7kDh6SQLhu4Tv0ec5f61xTSh2p+ULWCSESsLj7X3u8LfaGZQu19QHDSdMxl1ExtGZPAT Apcxn6OGIQubGIe6wIADxX6WIG86yyvBFtaPryqJGvn1em48eFCdtWOFdJ9RgMRmQN4FtMhnqYG+c chwnFahAnsnuSBDBZ21NAcbuRQQr1+AMtAdq1T1Vn+LGGaw/qJokmWQq+bZlDn+4zAp8PmagO2CGS tHeG8qJVU8xb5YH+A1OU4pZmw3mWgIa7cf1HgZYMlLcOGG7m8eNdwrrSTACHx61ok3pXNYD7PH+7N IAHHiEiEIeooISSQm20g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mngjR-007m48-Mm; Thu, 18 Nov 2021 12:41:37 +0000 Received: from mx08-00178001.pphosted.com ([91.207.212.93] helo=mx07-00178001.pphosted.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mngjM-007m3W-UM for linux-arm-kernel@lists.infradead.org; Thu, 18 Nov 2021 12:41:34 +0000 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1AI9ZkHS011332; Thu, 18 Nov 2021 13:41:22 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=selector1; bh=bZLyccCPkGwBC1ILuSoOqJaq32TOZCofwJur9eMV86c=; b=OgwKPvKIo8GkStXgpTIemvV3xjtrU71q80vfqsu+RPjq8KNkagcNevO+gMJu6Hefqm39 j8qU8SEVwUHIRg7S6MeMxrpqY2TPFRc9pgSE27MurQcQZfrenOKBOYY1PkPdXL7ir9uY hnC2b14uHPk+mZ29WUn2PWjvO5WEq60QQ1bnYyTYSZccmmyWUcEPorbcFZ/7/Fpmw0y0 a8TgtYC4QUatnBW6QRQlIIa4nOrS3X7R+dyT19VhVEyMWeBbXWtCJx81ptBWAQ6AsGxb NrUaPP+Yy22urQHSdNyFnj2YYTi9dslV/5ERtjW19OQcm3rWTFNEDx/IWb1Q+zE/ueTv ag== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3cdcvuumpd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 Nov 2021 13:41:22 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 2B35710002A; Thu, 18 Nov 2021 13:41:19 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node2.st.com [10.75.127.5]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 224BB2291A7; Thu, 18 Nov 2021 13:41:19 +0100 (CET) Received: from localhost (10.75.127.51) by SFHDAG2NODE2.st.com (10.75.127.5) with Microsoft SMTP Server (TLS) id 15.0.1497.26; Thu, 18 Nov 2021 13:41:18 +0100 From: Olivier Moysan To: Ahmad Fatoum , Alexandre Torgue , Fabrice Gasnier , Jonathan Cameron , Lars-Peter Clausen , Mauro Carvalho Chehab , Maxime Coquelin , Olivier Moysan , Wan Jiabing , Xu Wang CC: , , , Subject: [PATCH] iio: adc: stm32: fix null pointer on defer_probe error Date: Thu, 18 Nov 2021 13:39:52 +0100 Message-ID: <20211118123952.15383-1-olivier.moysan@foss.st.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.75.127.51] X-ClientProxiedBy: SFHDAG2NODE1.st.com (10.75.127.4) To SFHDAG2NODE2.st.com (10.75.127.5) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-11-18_05,2021-11-17_01,2020-04-07_01 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211118_044133_268444_74AA62E9 X-CRM114-Status: GOOD ( 17.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org dev_err_probe() calls __device_set_deferred_probe_reason() on -EPROBE_DEFER error. If device pointer to driver core private structure is not initialized, a null pointer error occurs. This pointer is set too late on iio_device_register() call, for iio device. So use parent device instead for dev_err_probe() call. Fixes: 0e346b2cfa85 ("iio: adc: stm32-adc: add vrefint calibration support") Signed-off-by: Olivier Moysan --- drivers/iio/adc/stm32-adc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c index 7f1fb36c747c..14c7c9d390e8 100644 --- a/drivers/iio/adc/stm32-adc.c +++ b/drivers/iio/adc/stm32-adc.c @@ -217,6 +217,7 @@ struct stm32_adc_cfg { /** * struct stm32_adc - private data of each ADC IIO instance + * dev: parent device * @common: reference to ADC block common data * @offset: ADC instance register offset in ADC block * @cfg: compatible configuration data @@ -243,6 +244,7 @@ struct stm32_adc_cfg { * @int_ch: internal channel indexes array */ struct stm32_adc { + struct device *dev; struct stm32_adc_common *common; u32 offset; const struct stm32_adc_cfg *cfg; @@ -1986,8 +1988,7 @@ static int stm32_adc_populate_int_ch(struct iio_dev *indio_dev, const char *ch_n /* Get calibration data for vrefint channel */ ret = nvmem_cell_read_u16(&indio_dev->dev, "vrefint", &vrefint); if (ret && ret != -ENOENT) { - return dev_err_probe(&indio_dev->dev, ret, - "nvmem access error\n"); + return dev_err_probe(adc->dev, ret, "nvmem access error\n"); } if (ret == -ENOENT) dev_dbg(&indio_dev->dev, "vrefint calibration not found\n"); @@ -2221,6 +2222,7 @@ static int stm32_adc_probe(struct platform_device *pdev) init_completion(&adc->completion); adc->cfg = (const struct stm32_adc_cfg *) of_match_device(dev->driver->of_match_table, dev)->data; + adc->dev = &pdev->dev; indio_dev->name = dev_name(&pdev->dev); indio_dev->dev.of_node = pdev->dev.of_node;