Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3183884pxb; Fri, 12 Feb 2021 11:16:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJxFtIAQfcKJhx4j+ZteufMdJipiL69tLvETFxFgNfUIT9POMwFgjStvhCF6k0Kn0scgBNIB X-Received: by 2002:a17:907:aa9:: with SMTP id bz9mr4313854ejc.528.1613157388454; Fri, 12 Feb 2021 11:16:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613157388; cv=none; d=google.com; s=arc-20160816; b=H85OGvuCGrpjhiuCe0HnlI/OxXIDpp2bTKPjIp73Z9b1KTCKYle09IgKjWf7u9o5zC bXByxZQBrowycxfo/a5PXisNrgwM1OvvJW851g0hc2w462aFvdbQxLNoyM1fEdIoxly8 nfFAb+E4IYCJztARfZTPE1PdGP9EnGA39S8ZBaB7okBFGVWUpgkZ4ld6rzUP4LalWWdQ JAA/xFn0FRPRXkVaBAHtLTORaEV4x8Wq3zUt3ywOJeEzZAS7PsBuAVcLYe3BrOpjH6m4 YuRFtQWLtE4e0CUweU7hTTawCo3bQyZ+sdpOI68HItn7hkzY9y3c8Mo6hN8IKUQ6468B XKAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=3m1bvLzzkOAaF03XO9LKHuan18uN8OCAt8VP7nRnMCo=; b=zbQ9kq4LmbEYdjI3N175ir9A08oCbU5Q9YZAXN8wczGB1XW9it0QJ724kLJqpAN+mQ nBAyVEO8iUwOmicU0z83oBCmR9C5Tx/Ai3IoyblI2elOOwYvtqc3Q5YVDQGKQCzoqwvq h74gNSAKku/27RlaTj4hkG/+kb0P8V0x8BxXq+GWRA2h/b4UVzP5SFc21urjTvmMA/ja H52X26l3pStQ6LBFdPjj7RwqslCIWRXrws3u1hzeZnuYaKScecRrqoyJlI6Qt8d7A7o2 m2XyEzh2y+/sKDGEmxc2+XWcJYmHIA2RDambs7iSRYYnjyy/MKJqomE108XNV3m1X6WV kwPA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bu13si6597577ejb.588.2021.02.12.11.16.04; Fri, 12 Feb 2021 11:16:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231790AbhBLTNJ convert rfc822-to-8bit (ORCPT + 99 others); Fri, 12 Feb 2021 14:13:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:36264 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231978AbhBLTNG (ORCPT ); Fri, 12 Feb 2021 14:13:06 -0500 Received: from archlinux (cpc108967-cmbg20-2-0-cust86.5-4.cable.virginm.net [81.101.6.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 57BF360241; Fri, 12 Feb 2021 19:12:23 +0000 (UTC) Date: Fri, 12 Feb 2021 19:12:19 +0000 From: Jonathan Cameron To: Petr =?UTF-8?B?xaB0ZXRpYXI=?= Cc: Tomasz Duszynski , Lars-Peter Clausen , Peter Meerwald-Stadler , stable@vger.kernel.org, Jonathan Cameron , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] iio: chemical: scd30: fix Oops due to missing parent device Message-ID: <20210212191219.7b16abbb@archlinux> In-Reply-To: <20210208223947.32344-1-ynezz@true.cz> References: <20210208223947.32344-1-ynezz@true.cz> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 8 Feb 2021 23:39:47 +0100 Petr Štetiar wrote: > My machine Oopsed while testing SCD30 sensor in interrupt driven mode: > > Unable to handle kernel NULL pointer dereference at virtual address 00000188 > pgd = (ptrval) > [00000188] *pgd=00000000 > Internal error: Oops: 5 [#1] SMP ARM > Modules linked in: > CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.4.96+ #473 > Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree) > PC is at _raw_spin_lock_irqsave+0x10/0x4c > LR is at devres_add+0x18/0x38 > ... > [<8070ecac>] (_raw_spin_lock_irqsave) from [<804916a8>] (devres_add+0x18/0x38) > [<804916a8>] (devres_add) from [<805ef708>] (devm_iio_trigger_alloc+0x5c/0x7c) > [<805ef708>] (devm_iio_trigger_alloc) from [<805f0a90>] (scd30_probe+0x1d4/0x3f0) > [<805f0a90>] (scd30_probe) from [<805f10fc>] (scd30_i2c_probe+0x54/0x64) > [<805f10fc>] (scd30_i2c_probe) from [<80583390>] (i2c_device_probe+0x150/0x278) > [<80583390>] (i2c_device_probe) from [<8048e6c0>] (really_probe+0x1f8/0x360) > > I've found out, that it's due to missing parent/owner device in iio_dev struct > which then leads to NULL pointer dereference during spinlock while registering > the device resource via devres_add(). > > Cc: # v5.9+ > Fixes: 64b3d8b1b0f5 ("iio: chemical: scd30: add core driver") > Signed-off-by: Petr Štetiar Hi Petr, So, we moved this into the core a while back (to avoid exactly this sort of issue). That change predates this introduction of this driver as it went in in v5.8 So I think you've hit an issue with a backport here to an earlier kernel? Jonathan > --- > drivers/iio/chemical/scd30_core.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/iio/chemical/scd30_core.c b/drivers/iio/chemical/scd30_core.c > index 4d0d798c7cd3..33aa6eb1963d 100644 > --- a/drivers/iio/chemical/scd30_core.c > +++ b/drivers/iio/chemical/scd30_core.c > @@ -697,6 +697,7 @@ int scd30_probe(struct device *dev, int irq, const char *name, void *priv, > > dev_set_drvdata(dev, indio_dev); > > + indio_dev->dev.parent = dev; > indio_dev->info = &scd30_info; > indio_dev->name = name; > indio_dev->channels = scd30_channels;