Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp900769pxb; Thu, 28 Jan 2021 03:14:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJz5F7YZnfpdJ0ARR265npWzA5X8kgDFpKAnxV2UaDtqJWhUN/n5cZy3VMyTTZW5QerSE7WT X-Received: by 2002:a05:6402:110b:: with SMTP id u11mr13928281edv.57.1611832448787; Thu, 28 Jan 2021 03:14:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611832448; cv=none; d=google.com; s=arc-20160816; b=s8pIgd/q5jDp5vSt7G67yJW/+e9sgxFbwTawa0YYStfhc5IQEpkPZUze/jEqMwmQFU dKji8VQwUNLtvAVU0RuLyiOOAMDnjo39nbZTPEjNwXGHE42+HafoUrnEtosm56blVrno VLP4knc7iNKL/AzanB33Wz+//r3Rvu0UYUsCcfx0a7jVg9sMYbHcQXOyXNgi332zrNRy QaLTc0ZnffFT6uqY2MFmWPgc2KgrML7pR9ptHz2MrXurC8xpB8s2x1BwoZ/g/vhc+zNq mkl9QrhfIKE/OSq9M8rKKx2YMSTLN/J7A22WrYualKOMpjygxCljPuK2hGelUEOMGyhE yigg== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=Wc9m/JnmNxTUyezxl8dfHXa1VJWNfgnlduZAZ6Tei40=; b=mjRM8vcXk2jClRL8O34L+97NXXXJli6o3OOl0UBoNr78aSpuBFKJCU+B5cwbXcIvIQ 4upM0ehmlLtvFqki1aAC7irMHrs1E1Wk0fs7pxUwHg+rSffc9vdFRwS5KCyoCUwjuaOH 4CC/IwnTbOzlOiP8MnYU8nhNihRudpBVW7GZF7XMJ1V8/6Zaa1yYaP29PZzrhr559HkS bRRjcJBaiVsWOWDAXh9ABKewDz7r8HaSRyYxrUcblKWkd0F9apyTSiAzs4TCrEmV4EvN vxSlQhJOFlO1iImWRp8z8guUFS9s/S28Dc+3zVdkXAssIFFD300Jn6pxSyzZWc66KRK8 kWHw== 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r23si2990799edy.113.2021.01.28.03.13.44; Thu, 28 Jan 2021 03:14:08 -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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229970AbhA1LNA (ORCPT + 99 others); Thu, 28 Jan 2021 06:13:00 -0500 Received: from foss.arm.com ([217.140.110.172]:56800 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229586AbhA1LM4 (ORCPT ); Thu, 28 Jan 2021 06:12:56 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 102441FB; Thu, 28 Jan 2021 03:12:11 -0800 (PST) Received: from slackpad.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D0A833F7D8; Thu, 28 Jan 2021 03:12:08 -0800 (PST) Date: Thu, 28 Jan 2021 11:11:28 +0000 From: Andre Przywara To: Dmitry Torokhov Cc: Maxime Ripard , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Icenowy Zheng , Rob Herring , =?UTF-8?B?Q2zDqW1lbnQgUMOpcm9u?= , Shuosheng Huang , Yangtao Li , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Lee Jones , linux-input@vger.kernel.org, Mark Brown Subject: Re: [PATCH v5 05/20] Input: axp20x-pek: Bail out if AXP has no interrupt line connected Message-ID: <20210128104627.76b35a5c@slackpad.fritz.box> In-Reply-To: References: <20210127172500.13356-1-andre.przywara@arm.com> <20210127172500.13356-6-andre.przywara@arm.com> Organization: Arm Ltd. X-Mailer: Claws Mail 3.17.1 (GTK+ 2.24.31; x86_64-slackware-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 27 Jan 2021 11:42:15 -0800 Dmitry Torokhov wrote: Hi Dmitry, thanks for your feedback! > On Wed, Jan 27, 2021 at 05:24:45PM +0000, Andre Przywara wrote: > > On at least one board (Orangepi Zero2) the AXP305 PMIC does not have its > > interrupt line connected to the CPU (mostly because the H616 SoC does > > not feature an NMI pin anymore). > > After allowing the AXP driver to proceed without an "interrupts" > > property [1], the axp20x-pek driver crashes with a NULL pointer > > dereference (see below). > > > > Check for the regmap_irqc member to be not NULL before proceeding with > > probe. This gets normally filled by the call to regmap_add_irq_chip(), > > which we allow to skip now, when the DT node lacks an interrupt > > property. > > No, the driver is not the right place to patch this; regmap should be > fixed so it does not crash instead. I am not sure this is the right approach, those regmap functions look more like an internal interface to me, with lots of wrapper functions happily dereferencing pointers and reaching into structs. Moving NULL checks into those does not sound like the right thing. CC:ing Mark for more opinions on this. A more general solution would be to not instantiate this driver here at all, when we don't have an interrupt line. However at the moment the AXP MFD driver uses a const struct to hold all MFD cells, so there is no easy way of omitting the power key device dynamically. And even then it would hard code the requirement for an interrupt into the MFD driver, when this could be considered an implementation detail of the axp20x-pek driver. That's why I came up with this patch here, which was the easiest and cleanest: This driver *requires* a valid regmap_irqc, so it should verify this at probe time, kind of like a normal driver would bail out if no IRQ line could be reserved. Let me know what you think! Cheers, Andre