From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09BE2C433DB for ; Sat, 2 Jan 2021 18:20:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CA4BC207CD for ; Sat, 2 Jan 2021 18:20:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726628AbhABSUA (ORCPT ); Sat, 2 Jan 2021 13:20:00 -0500 Received: from os.inf.tu-dresden.de ([141.76.48.99]:44658 "EHLO os.inf.tu-dresden.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726617AbhABSUA (ORCPT ); Sat, 2 Jan 2021 13:20:00 -0500 Received: from erwin.inf.tu-dresden.de ([141.76.48.80] helo=l4re.org) by os.inf.tu-dresden.de with esmtp (Exim 4.94) id 1kvlBB-0007bz-Tx; Sat, 02 Jan 2021 18:59:06 +0100 From: Adam Lackorzynski To: maz@kernel.org, tglx@linutronix.de Cc: linux-arm-kernel@lists.infradead.org, linusw@kernel.org, kaloz@openwrt.org, khalasa@piap.pl, andrew@lunn.ch, gregory.clement@bootlin.com, sebastian.hesselbarth@gmail.com, linux-gpio@vger.kernel.org, bgolaszewski@baylibre.com Subject: [PATCH 6/6] x86/ioapic: Fix return check of __irq_domain_alloc_irqs Date: Sat, 2 Jan 2021 18:58:59 +0100 Message-Id: <20210102175859.335447-6-adam@l4re.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210102175859.335447-1-adam@l4re.org> References: <20210102175859.335447-1-adam@l4re.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org 0 is not a proper IRQ number and also indicates failure. Also check for this case in upwards functions. Signed-off-by: Adam Lackorzynski --- arch/x86/kernel/apic/io_apic.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c index e4ab4804b20d..8ae46a092c88 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c @@ -1007,7 +1007,7 @@ static int alloc_isa_irq_from_domain(struct irq_domain *domain, info->flags |= X86_IRQ_ALLOC_LEGACY; irq = __irq_domain_alloc_irqs(domain, irq, 1, node, info, true, NULL); - if (irq >= 0) { + if (irq > 0) { irq_data = irq_domain_get_irq_data(domain, irq); data = irq_data->chip_data; data->isa_irq = true; @@ -1050,10 +1050,11 @@ static int mp_map_pin_to_irq(u32 gsi, int idx, int ioapic, int pin, irq = alloc_irq_from_domain(domain, ioapic, gsi, &tmp); else if (!mp_check_pin_attr(irq, &tmp)) irq = -EBUSY; - if (irq >= 0) { + if (irq > 0) { data = irq_get_chip_data(irq); data->count++; - } + } else if (irq == 0) + irq = -ENOENT; } mutex_unlock(&ioapic_mutex); -- 2.30.0.rc2 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6358AC4332B for ; Sat, 2 Jan 2021 18:01:19 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 255ED207AF for ; Sat, 2 Jan 2021 18:01:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 255ED207AF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=l4re.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=LDYhADTnDCCweKo9mAv+6SWmLPTDhpgYM4y/Vwf424Q=; b=ywxWt0PzmuSAHUYC4rEkjYxf/ 8OtW7pft7sgkEtvyMZ4jxomyj1LmveQ9TANqYFlkcEG3ZOlZp/JFzq4vA53/64ni7Lc+5OFEEXT1Z 1kr7JgycvkASz2fUR+t6fnlRYAHWvcavgb31kSJmHDymy2CrqkRF1V2xzFHJVnWbPAWGmmnEPvS/D ACNumVTjUudFWmPN24DDYUxwggremNC8vGPYpczjyKYYUnS9g5dykdTJ3lcSUEDQuIErRrUTvvdiV oWH6QrHyAV5DvmeeYHINyUVxtBcXmI0klebp25UKEbNBfCA4DpGHwutB2SMp0b3EQd74qEZvLCreH Fg31xKdZg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kvlBR-000455-Hw; Sat, 02 Jan 2021 17:59:21 +0000 Received: from os.inf.tu-dresden.de ([141.76.48.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kvlBH-00041m-Ec for linux-arm-kernel@lists.infradead.org; Sat, 02 Jan 2021 17:59:13 +0000 Received: from erwin.inf.tu-dresden.de ([141.76.48.80] helo=l4re.org) by os.inf.tu-dresden.de with esmtp (Exim 4.94) id 1kvlBB-0007bz-Tx; Sat, 02 Jan 2021 18:59:06 +0100 From: Adam Lackorzynski To: maz@kernel.org, tglx@linutronix.de Subject: [PATCH 6/6] x86/ioapic: Fix return check of __irq_domain_alloc_irqs Date: Sat, 2 Jan 2021 18:58:59 +0100 Message-Id: <20210102175859.335447-6-adam@l4re.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210102175859.335447-1-adam@l4re.org> References: <20210102175859.335447-1-adam@l4re.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210102_125911_660294_BE05C70F X-CRM114-Status: GOOD ( 10.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: andrew@lunn.ch, bgolaszewski@baylibre.com, linusw@kernel.org, linux-gpio@vger.kernel.org, khalasa@piap.pl, kaloz@openwrt.org, gregory.clement@bootlin.com, linux-arm-kernel@lists.infradead.org, sebastian.hesselbarth@gmail.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 0 is not a proper IRQ number and also indicates failure. Also check for this case in upwards functions. Signed-off-by: Adam Lackorzynski --- arch/x86/kernel/apic/io_apic.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c index e4ab4804b20d..8ae46a092c88 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c @@ -1007,7 +1007,7 @@ static int alloc_isa_irq_from_domain(struct irq_domain *domain, info->flags |= X86_IRQ_ALLOC_LEGACY; irq = __irq_domain_alloc_irqs(domain, irq, 1, node, info, true, NULL); - if (irq >= 0) { + if (irq > 0) { irq_data = irq_domain_get_irq_data(domain, irq); data = irq_data->chip_data; data->isa_irq = true; @@ -1050,10 +1050,11 @@ static int mp_map_pin_to_irq(u32 gsi, int idx, int ioapic, int pin, irq = alloc_irq_from_domain(domain, ioapic, gsi, &tmp); else if (!mp_check_pin_attr(irq, &tmp)) irq = -EBUSY; - if (irq >= 0) { + if (irq > 0) { data = irq_get_chip_data(irq); data->count++; - } + } else if (irq == 0) + irq = -ENOENT; } mutex_unlock(&ioapic_mutex); -- 2.30.0.rc2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel