From patchwork Wed Jul 24 08:40:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ma Ke X-Patchwork-Id: 814860 Received: from cstnet.cn (smtp21.cstnet.cn [159.226.251.21]) (using TLSv1.2 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7AB51420A8; Wed, 24 Jul 2024 08:41:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.226.251.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721810483; cv=none; b=HanmVu9l3S3ih4avfguEDFJVIXXDJwHrkhdWlMUJr7+nXYl9wvq8/E+RCg3okVxWMIUJVEkzWmfDRUdR8ih8l3UIumuBrBDi9cVjXbpn+ix3imMM/ugSBeJ8hCwGQe8ltV4TqxH0K/kxM6f+r9sKEpkDBsZS4HzJFrbSJYLKJmg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721810483; c=relaxed/simple; bh=K6zEVcmV44vyvWLvVCMoZbnOgMdcpc7IwtNVbeauj+U=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=opQkgBvYOU3Y/FNEQd84gdWUnwicPCoCSbCviKqIlEVU0IuUaSdk0hf9bwvpFIjRfKbd+KgPsVe+2J8KhLWgYosoaE8NY0WL+Sq5XuP1HCbdJGNkMlPT+scbwNzDBs0uFQB+Zpipy2MmaSo2hTfergWQ6uw+kG3r4nTq3gJGON0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn; spf=pass smtp.mailfrom=iscas.ac.cn; arc=none smtp.client-ip=159.226.251.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iscas.ac.cn Received: from icess-ProLiant-DL380-Gen10.. (unknown [183.174.60.14]) by APP-01 (Coremail) with SMTP id qwCowAC3v0sVvqBmUs28AA--.40499S2; Wed, 24 Jul 2024 16:40:55 +0800 (CST) From: Ma Ke To: broonie@kernel.org, jwboyer@linux.vnet.ibm.com, weo@reccoware.de, sfalco@harris.com, sr@denx.de, dbrownell@users.sourceforge.net Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Ma Ke Subject: [PATCH v4] spi: ppc4xx: handle irq_of_parse_and_map() errors Date: Wed, 24 Jul 2024 16:40:47 +0800 Message-Id: <20240724084047.1506084-1-make24@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: qwCowAC3v0sVvqBmUs28AA--.40499S2 X-Coremail-Antispam: 1UD129KBjvdXoW7JrWfuF17Kr4DCr4kZF43KFg_yoWDAwb_Cw 1fu392grWUCwnaka1jgr4fAry09345Ww1vvr92qF9xtrWDJFnFv34IvF1UXaySkF4UCF1j kw1DXFy5urnIqjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbVAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr0_ Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAac4AC62xK8xCEY4vEwIxC4wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC 0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr 1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IE rcIFxwCY1x0262kKe7AKxVWUtVW8ZwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbV WUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF 67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42 IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF 0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxh VjvjDU0xZFpf9x0JUQvtAUUUUU= X-CM-SenderInfo: ppdnvj2u6l2u1dvotugofq/ Zero and negative number is not a valid IRQ for in-kernel code and the irq_of_parse_and_map() function returns zero on error. So this check for valid IRQs should only accept values > 0. Fixes: 44dab88e7cc9 ("spi: add spi_ppc4xx driver") Signed-off-by: Ma Ke --- Changes in v4: - fixed a typo in v3. Sorry for the error in the patch v3. Changes in v3: - removed Cc stable line as suggestions. Changes in v2: - added Cc stable line; - added Fixes line. --- drivers/spi/spi-ppc4xx.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/spi/spi-ppc4xx.c b/drivers/spi/spi-ppc4xx.c index 942c3117ab3a..01fdecbf132d 100644 --- a/drivers/spi/spi-ppc4xx.c +++ b/drivers/spi/spi-ppc4xx.c @@ -413,6 +413,9 @@ static int spi_ppc4xx_of_probe(struct platform_device *op) /* Request IRQ */ hw->irqnum = irq_of_parse_and_map(np, 0); + if (hw->irqnum <= 0) + goto free_host; + ret = request_irq(hw->irqnum, spi_ppc4xx_int, 0, "spi_ppc4xx_of", (void *)hw); if (ret) {