Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp473930pxa; Wed, 19 Aug 2020 06:43:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+msi0zxYORC3P34NkiA2Pg4KZXXwFa9dwgl8ELa4dbRhWIwSGo7K+gHG23+fLcgDZRIPP X-Received: by 2002:a17:906:7b83:: with SMTP id s3mr24808355ejo.2.1597844635429; Wed, 19 Aug 2020 06:43:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597844635; cv=none; d=google.com; s=arc-20160816; b=ONqFXGaTAYD8qEW3/dBPDKjNEWyu2RRGCHcGx7agVQD5dEUi0lYtzcSbR8k3delepJ eQzR5KfuIgkErUXAl5Oq0dWj5oIqAuCS2dBrvTEQ7PZOQO7xRNKmJPaMQJhTFdLWQOQH i4GAFJoT09buMGxmkRELv6gl5psBTgOmjRs26zKWftZ8FsSxV87S5vbU9o934LLena4Y N38vnb40JRepMyuNGHB5YKIiIGfgBumFI+QfvuiDFNLRoVRZ4KR2Msqvq8+KyDVzDUvh nC8JfyV3GS2zENOBxVxDvO9p2dy9qbrMDq+DPFuXPaTgLQoVtHOQ4OSSH28mpAXbWLST CPOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature; bh=9BKZNUgLBYBiXPWyPP3TIXvCSK+vmcsuX59tZG0lpPU=; b=MNcxbWUlJoBYfUjr7LY2NMrv6sUCOnzx6OJCenhBu7fyGCA3xtbUHoeLuSmdKibXO/ e2rQcs7Bj++ZuRCCHSyWaBriJ+OtbFSc5Jn5KQN3qBHsE8bSGdPtcGf8IJbn7qh7k4cY mnnMeCeqYIt+bD5kW07EyNPJKUKpPFpu3GMfnlEYwKBWsIftqF7VPSLE2QY0hcSDARZ4 kDAfbAr8l1totTp3GGtUYONaGvlvQP36zwuQDyC7MfJ3YZSLfXLZ9tcQm0TFUV1t84gb lEReVYmNlx/X20wAkPqx8lgGTX4jRnj8pCehlv51RX6vZQvnO6lbhuebxJtiR5K3qg8N kl7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="X2p4tG/l"; 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 bd9si15705845edb.340.2020.08.19.06.43.30; Wed, 19 Aug 2020 06:43: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; dkim=pass header.i=@kernel.org header.s=default header.b="X2p4tG/l"; 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 S1728241AbgHSNmw (ORCPT + 99 others); Wed, 19 Aug 2020 09:42:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:55128 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727046AbgHSNmu (ORCPT ); Wed, 19 Aug 2020 09:42:50 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (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 B3F5E204FD; Wed, 19 Aug 2020 13:42:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597844569; bh=nRHlZ1MnhuRCWEVlVgqtKUWgqsrlzs+w4Nj+dZAbawc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=X2p4tG/lI4UDoGQ0sW7iBjo5mfR7OsNSzk2uNq3Xhim97qLQo2BUAax5CH6LxWxQ3 SyLd/JY3Anlf1Vkm7UkfpDCr9hyV2G5dviys/6P/0z35NeRRb/G3vtxR+wiuYLfK9Q CM9M4FOLugd4F74QfZ7XQFOx/6L3XtyEgHhh141s= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1k8OMa-004DzN-87; Wed, 19 Aug 2020 14:42:48 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 19 Aug 2020 14:42:48 +0100 From: Marc Zyngier To: Mark-PK Tsai Cc: alix.wu@mediatek.com, daniel@0x0f.com, devicetree@vger.kernel.org, jason@lakedaemon.net, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, matthias.bgg@gmail.com, robh+dt@kernel.org, tglx@linutronix.de, yj.chiang@mediatek.com Subject: Re: [PATCH 1/2] irqchip: irq-mst: Add MStar interrupt controller support In-Reply-To: (raw) References: (raw) User-Agent: Roundcube Webmail/1.4.7 Message-ID: X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: mark-pk.tsai@mediatek.com, alix.wu@mediatek.com, daniel@0x0f.com, devicetree@vger.kernel.org, jason@lakedaemon.net, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, matthias.bgg@gmail.com, robh+dt@kernel.org, tglx@linutronix.de, yj.chiang@mediatek.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-08-19 14:31, Mark-PK Tsai wrote: > From: Marc Zyngier > >> > + >> > +static int mst_intc_domain_alloc(struct irq_domain *domain, unsigned >> > int virq, >> > + unsigned int nr_irqs, void *data) >> > +{ >> > + int i; >> > + irq_hw_number_t hwirq; >> > + struct irq_fwspec parent_fwspec, *fwspec = data; >> > + struct mst_intc_chip_data *cd = (struct mst_intc_chip_data >> > *)domain->host_data; >> >> No cast necessary here. >> >> > + >> > + /* Not GIC compliant */ >> > + if (fwspec->param_count != 3) >> > + return -EINVAL; >> > + >> > + /* No PPI should point to this domain */ >> > + if (fwspec->param[0]) >> > + return -EINVAL; >> > + >> > + if (fwspec->param[1] >= cd->nr_irqs) >> >> This condition is bogus, as it doesn't take into account the nr_irqs >> parameter. >> > > > The hwirq number need to be in the irq map range. (property: > mstar,irqs-map-range) > If it's not, it must be incorrect configuration. I agree. And since you are checking whether the configuration is correct, it'd better be completely correct. > So how about use the condition as following? > > if (hwirq >= cd->nr_irqs) > return -EINVAL; Again, this says nothing of the validity of (hwirq + nr_irqs - 1)... > >> > + return -EINVAL; >> > + >> > + hwirq = fwspec->param[1]; >> > + for (i = 0; i < nr_irqs; i++) >> > + irq_domain_set_hwirq_and_chip(domain, virq + i, hwirq + i, >> > + &mst_intc_chip, >> > + domain->host_data); ... which you are using here. M. -- Jazz is not dead. It just smells funny...