Received: by 2002:a05:7412:8d08:b0:f9:2d0a:d759 with SMTP id bj8csp168367rdb; Sun, 17 Dec 2023 06:54:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IGVhWtMh2C89o4lW1KKk6vh+bRlpjLh2tfsKE0+yzHg1pYf0pDo4DIrXGksa+1BnSCcxNw1 X-Received: by 2002:a9d:69d2:0:b0:6d9:a81b:3735 with SMTP id v18-20020a9d69d2000000b006d9a81b3735mr17142668oto.45.1702824850494; Sun, 17 Dec 2023 06:54:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702824850; cv=none; d=google.com; s=arc-20160816; b=gk/nUAdLACApHStTel+01IPYrWhpKtl/fKpM7stma70kn1W6b5uR4kpdZurjC3tSIS cFW//z3M5zKM44xwpWk9VPcvAmRNjP8cwdpVvJWOR/SfJobtcHSdrv4i6dnkOmWpb6T5 rLVAGzQYkUs/6Kn0/Q+BaWGx36m92oJK+hMApTk98DOus1cCLg2vlCT3N3DQig4Y7zr5 NiAqK4fTFVmQTVDv07Unn7MHaNLFLrP0A++lz9IIhQIiZEExmz+5f63UmllicNRUuWLJ O7DF8+QYAw2Cp1rvcIfes4b2kpzg1uXo6bm9eT7ET6XCbsVv1NH5adtIy6pL3Yvu+7Cg NmnQ== 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 :subject:cc:to:from:date:dkim-signature; bh=IibleC9KZJaYeWO7FdD45wGwvhgC30BgPTGfG5s3yY8=; fh=IYtYDItZhYxUobJUE4h/DPNfo4t2DYpfZJxUzFo9Hpw=; b=PNIMdXVd0X0Nx6OC21tLueBWHYNLGMWZ0NZhnv6+0OW5Q79IqUGatWsuTX7p/DPU9g 853Uu/p4ST6c1FMIGaiusLrDseQQYsYm6abL8JO8r8qKQ+9kQ1IoxPlgYu0Qe+OwpvSz z1jrMnr2D6gzjJTbn5xMfLB153d3+6MMF1Z9SXDqqsi660MZGgapsM8vfXy++kGacvJZ GU1hkQW+PDzXyAZEhpQX7xDCrjIAKnKAkAhBFBqQdsC9dzmKMyJEM9NY1yQm4CMcWA8C sW94je2X19GV6pS3/TYmlTFsH8mbWovzptdmOUqWuGI6XsAMssG34Id8UPeDDIOyDU0J d/eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="P2g/+f/y"; spf=pass (google.com: domain of linux-kernel+bounces-2655-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2655-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id ei17-20020a056a0080d100b006d45aab6faasi1950565pfb.40.2023.12.17.06.54.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 06:54:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2655-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="P2g/+f/y"; spf=pass (google.com: domain of linux-kernel+bounces-2655-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2655-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 51F47B226BF for ; Sun, 17 Dec 2023 14:54:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7A47644C80; Sun, 17 Dec 2023 14:53:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="P2g/+f/y" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 A699A44C65; Sun, 17 Dec 2023 14:53:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 101D2C433C7; Sun, 17 Dec 2023 14:53:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702824837; bh=6PGHltDeG6Yd1WWUHaZuRnIsh7dV91pqbP7IA10PJq4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=P2g/+f/yDvBFCk9s4x2scwHc4cEIJCnMzcJ6qi6bjWmNgcQtxPizQ5C9UxVnejo1g FXh1cOwgHJRbYNb2ATiA9FNcvctYMx8NJ4Vi8AkARMjY4auBZa7GRjgJa9GlSRH5Xd Rh+p44maDqZpNe1HnbhRAXuKOnDfO8zTJUvnvMvgOkfhug24xZvPNOgOOnw5HnAP0+ m7OWXXCEbw0jH32s33D24q/pwaH8eqviRYcDITkJVqs/6FUSxs1iSuU1VrZsYB7nD8 R47y/ctNwCHXhR3hN1L8yKIb52JZFknX2Og9rqu0qTyVN2aHaCv9TiRHeh6eLRH7x0 D/5/wQMXcQkIg== Date: Sun, 17 Dec 2023 14:53:39 +0000 From: Jonathan Cameron To: Marcelo Schmitt Cc: , , , , , , , , , , , , , , , Subject: Re: [PATCH v4 02/15] iio: adc: ad7091r: Pass iio_dev to event handler Message-ID: <20231217145339.1ec0e1cd@jic23-huawei> In-Reply-To: <5024b764107463de9578d5b3b0a3d5678e307b1a.1702746240.git.marcelo.schmitt1@gmail.com> References: <5024b764107463de9578d5b3b0a3d5678e307b1a.1702746240.git.marcelo.schmitt1@gmail.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.38; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sat, 16 Dec 2023 14:46:11 -0300 Marcelo Schmitt wrote: > 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 Given we are late in the cycle, I've applied this to the togreg branch of iio.git and it will hopefully go in during the merge window rather than before. Marked it for stable though so should get backported appropriately. Thanks, Jonathan > --- > 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; > }