Received: by 2002:a05:7412:8d23:b0:f7:29d7:fb05 with SMTP id bj35csp328908rdb; Sat, 16 Dec 2023 09:47:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IGvldQv547ZkKgX5NpP1wxJDu0dl/wioiw3V7rTVUcfeVlpwHedSM1vG9VL8E3D2E79uoKb X-Received: by 2002:ac8:5f88:0:b0:425:7f98:383d with SMTP id j8-20020ac85f88000000b004257f98383dmr19078023qta.66.1702748821972; Sat, 16 Dec 2023 09:47:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702748821; cv=none; d=google.com; s=arc-20160816; b=I7zh5iO/QhX3qyy7yE2uZqvOboCpHX5ijybiCo7wVv8bDPaocCOqt4pR3toVFviyDY kBc0qjEDcat67dus8f1+ydD/zX4AOm7mpyz0uz9QgkxVV29GkqROL7VGCIubVqJo+Q6K sfVZchcHSgI5sV75eMETeWNPNlwHZwxbPYZtWO2EaAaizPUQuFgGNPy3XjjLEfxXdbxR oXD9OdPyItf7bRBtH7RKdMCH286ktFjlMIW+kY2ZbYRVdrl7M3iQ+GPs8OuizSncSkXR Od4iDM1s5rHK/dlqJVfDeY7BahVvYHaz5eUlQzaRoOT00cHA6WZql9EruhsSjyj3VHeh pxjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=SgrZQB12wfpBZCCmCh8xD+NVNX7s8uQVPGylPNWAB1M=; fh=QwEOK/MZnBUTBQAzGwecl0DPfALWXdlHbxPQlQn9VIw=; b=WuaTXnSZ5lK0w3HOFz1oxF8+IlPfk+qINawY43AlJauG6XGVQyIUA6FnVxr/Ajys+G d+jYfpSH1GMrRfahx23zBB6NV6veD5kb30WSwRkDnuxn+ssOoRhAV3UkYWlFvmALYVwi FDMXPcGFcWIHDhoutWQ1Y1H08OQ1D0LcC+lkZx/V8s1oo19bJyz9usGJIOY3CTVUE+Py 9OIp1WdrnBDLTfEM58uf15ZX8rkDkMUaLfUBbmKJPHu820puK5ezKXY7SjKWK4QG69yB 985ibDCBuLU665q8b1nlEVn9QtetmFDhp6nrSGWHdxemLb05XufDbQzr7sxkXwMVrFgX DbLw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-2300-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2300-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=analog.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id n11-20020a05622a11cb00b00423c16e9127si21966369qtk.551.2023.12.16.09.47.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Dec 2023 09:47:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2300-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-2300-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2300-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=analog.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B80791C21889 for ; Sat, 16 Dec 2023 17:47:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AB34730FBC; Sat, 16 Dec 2023 17:46:54 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from mx0a-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0A8A30F83; Sat, 16 Dec 2023 17:46:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=analog.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=analog.com Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 3BGFkOoc011764; Sat, 16 Dec 2023 12:46:32 -0500 Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 3v1etvg8m4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 16 Dec 2023 12:46:32 -0500 (EST) Received: from ASHBMBX8.ad.analog.com (ASHBMBX8.ad.analog.com [10.64.17.5]) by nwd2mta3.analog.com (8.14.7/8.14.7) with ESMTP id 3BGHkVkR033908 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sat, 16 Dec 2023 12:46:31 -0500 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Sat, 16 Dec 2023 12:46:30 -0500 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Sat, 16 Dec 2023 12:46:29 -0500 Received: from work.ad.analog.com (HYB-hERzalRezfV.ad.analog.com [10.65.205.129]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 3BGHkDeN015764; Sat, 16 Dec 2023 12:46:16 -0500 From: Marcelo Schmitt To: , , , , , , , , , , , , , CC: , , Subject: [PATCH v4 02/15] iio: adc: ad7091r: Pass iio_dev to event handler Date: Sat, 16 Dec 2023 14:46:11 -0300 Message-ID: <5024b764107463de9578d5b3b0a3d5678e307b1a.1702746240.git.marcelo.schmitt1@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-GUID: XdpzOX4Fxa9kUti580OORDGqXStsvpkB X-Proofpoint-ORIG-GUID: XdpzOX4Fxa9kUti580OORDGqXStsvpkB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-02_01,2023-11-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=880 suspectscore=0 adultscore=0 clxscore=1015 bulkscore=0 mlxscore=0 impostorscore=0 spamscore=0 malwarescore=0 lowpriorityscore=0 phishscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2312160137 Previous version of ad7091r event handler received the ADC state pointer and retrieved the iio device from driver data field with dev_get_drvdata(). However, no driver data have ever been set, which led to null pointer dereference when running the event handler. Pass the iio device to the event handler and retrieve the ADC state struct from it so we avoid the null pointer dereference and save the driver from filling the driver data field. Fixes: ca69300173b6 ("iio: adc: Add support for AD7091R5 ADC") Signed-off-by: Marcelo Schmitt --- drivers/iio/adc/ad7091r-base.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/adc/ad7091r-base.c b/drivers/iio/adc/ad7091r-base.c index 8e252cde735b..0e5d3d2e9c98 100644 --- a/drivers/iio/adc/ad7091r-base.c +++ b/drivers/iio/adc/ad7091r-base.c @@ -174,8 +174,8 @@ static const struct iio_info ad7091r_info = { static irqreturn_t ad7091r_event_handler(int irq, void *private) { - struct ad7091r_state *st = (struct ad7091r_state *) private; - struct iio_dev *iio_dev = dev_get_drvdata(st->dev); + struct iio_dev *iio_dev = private; + struct ad7091r_state *st = iio_priv(iio_dev); unsigned int i, read_val; int ret; s64 timestamp = iio_get_time_ns(iio_dev); @@ -234,7 +234,7 @@ int ad7091r_probe(struct device *dev, const char *name, if (irq) { ret = devm_request_threaded_irq(dev, irq, NULL, ad7091r_event_handler, - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, name, st); + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, name, iio_dev); if (ret) return ret; } -- 2.42.0