Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4471442pxb; Sat, 6 Nov 2021 14:47:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoYCxpckUopG1RTpju6w0IhEd7Ot3OkEP0QFDDcf6UXnOvL4UIAY6WBZ3msOirWh7sVq9V X-Received: by 2002:a05:6402:34d0:: with SMTP id w16mr59670590edc.360.1636235275567; Sat, 06 Nov 2021 14:47:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636235275; cv=none; d=google.com; s=arc-20160816; b=eKhrsmKXXStl67AKu/hmUMKE3MiCQDNWpj6krD4iJz9QF8IdA2wc1JEWrBdxDwrdtC Zocvu3A09XjqBRMYA470EfncQabtJKsbXx7L6ljVjoHJjZwoWwyY8m/8uxPqrUuPh4HT LQFG2y57Aq/W3PgdJK0uwJO4VsVFX8uVMqBW4kycX0HD9wnt0Bo4Dz73Rwy3mzjhSoYc rk9hNjUSTN+f5cNo/Ex9X6PciUFDk6VykelvP4DZSFIX8iR6/8QddpV0gSQzh0ZHlB1V DpovLOuKyFIWi8A3/LilfSDSO27Q8PSB4fFhBuOmM+zvzJPcco/2tb02d2Vf071UjMWx 2TFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:user-agent:date:message-id:organization:subject:from :cc:to:dkim-filter; bh=s6N8ap+QKpfv+Rngohy4B1PVXcufgmGN0rR528nzG20=; b=qqVmog90DB1Lb2mB8OZ+RTlnGIZHMmpwSfQl0A4zsuXlhF77QWuK7UOqFfnEQC2cWY sNSTSqXCUeBaRL8P0W77YunaGN5U7rdBVO3RAuk/tcmuwoilePToS15MR2MGLZUTKcb2 4F9ib/3HSzjVtPdCcG9isKHKiWWsoxIKk6wJFH6XEQpRtjI0+3+38DsdTfHxGPQvi0bk UMBzET/UwS4xHCLm4sw7IOXI7S814Yr29A+htZTJXwltAUVDgakR5GCQJX5ggLyKlhdh nCAhF3E6jKXM3Wuq+9YVOVrQW3R7J+WF/S+M/QYAjnsdp4pfNqmLyZOLcjTy6qN0isnu fFKw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w12si23660054edj.252.2021.11.06.14.47.32; Sat, 06 Nov 2021 14:47:55 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235041AbhKFU3k (ORCPT + 99 others); Sat, 6 Nov 2021 16:29:40 -0400 Received: from mxout02.lancloud.ru ([45.84.86.82]:42480 "EHLO mxout02.lancloud.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233034AbhKFU3k (ORCPT ); Sat, 6 Nov 2021 16:29:40 -0400 Received: from LanCloud DKIM-Filter: OpenDKIM Filter v2.11.0 mxout02.lancloud.ru 738622293339 Received: from LanCloud Received: from LanCloud Received: from LanCloud To: Greg Kroah-Hartman , "Rafael J. Wysocki" CC: From: Sergey Shtylyov Subject: [PATCH] platform: finally disallow IRQ0 in platform_get_irq() and its ilk Organization: Open Mobile Platform Message-ID: <5e001ec1-d3f1-bcb8-7f30-a6301fd9930c@omp.ru> Date: Sat, 6 Nov 2021 23:26:47 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [192.168.11.198] X-ClientProxiedBy: LFEXT02.lancloud.ru (fd00:f066::142) To LFEX1907.lancloud.ru (fd00:f066::207) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The commit a85a6c86c25b ("driver core: platform: Clarify that IRQ 0 is invalid") only calls WARN() when IRQ0 is about to be returned, however using IRQ0 is considered invalid (according to Linus) outside the arch/ code where it's used by the i8253 drivers. Many driver subsystems treat 0 specially (e.g. as an indication of the polling mode by libata), so the users of platform_get_irq[_byname]() in them would have to filter out IRQ0 explicitly and this (quite obviously) doesn't scale... Let's finally get this straight and return -EINVAL instead of IRQ0! Fixes: a85a6c86c25b ("driver core: platform: Clarify that IRQ 0 is invalid") Signed-off-by: Sergey Shtylyov --- The patch is against the 'driver-core-linus' branch of Greg Kroah-Hartman's 'driver-core.git' repo. drivers/base/platform.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) Index: driver-core/drivers/base/platform.c =================================================================== --- driver-core.orig/drivers/base/platform.c +++ driver-core/drivers/base/platform.c @@ -231,7 +231,8 @@ int platform_get_irq_optional(struct pla out_not_found: ret = -ENXIO; out: - WARN(ret == 0, "0 is an invalid IRQ number\n"); + if (WARN(!ret, "0 is an invalid IRQ number\n")) + return -EINVAL; return ret; } EXPORT_SYMBOL_GPL(platform_get_irq_optional); @@ -445,7 +446,8 @@ static int __platform_get_irq_byname(str r = platform_get_resource_byname(dev, IORESOURCE_IRQ, name); if (r) { - WARN(r->start == 0, "0 is an invalid IRQ number\n"); + if (WARN(!r->start, "0 is an invalid IRQ number\n")) + return -EINVAL; return r->start; }