From nobody Wed Apr 8 01:39:18 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33117C32793 for ; Wed, 24 Aug 2022 12:30:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237496AbiHXMaf (ORCPT ); Wed, 24 Aug 2022 08:30:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237457AbiHXMaZ (ORCPT ); Wed, 24 Aug 2022 08:30:25 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 227D05B060 for ; Wed, 24 Aug 2022 05:30:24 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id w29so10777541pfj.3 for ; Wed, 24 Aug 2022 05:30:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=jx5D2mTV+ExxV8ji9PCBz7vQf+NrUEKj5YJ/dsZ+EGc=; b=lUY19Y9Hd9OS3UivjnlZCoXY1Bh/MTUqfkDMO9l+Ox5gj32ooZicggfrJnvlMXKAxd i6VcOEC9xDtmg24ihkGf9Bwg0RxIXqixVTMjVD+GZeN7ef5DdDVkFH5+DHSC9RPtO9V4 jth5ptsa24LpkiVe5qvE6wUGZyi5npyqj+m8k2axWb3fVLkZTlxCuzsOTa0xXY21QB6Z gEp/5lAH7mxAkaw1gmfsBWG/yAv9K3ssyIdSpy2Lxcuvv6q1JlNqo2goBU4dYUOOoif2 BnMNA10IN8KB8dU0VZdV/C4Uo43b7vpAVGp3FCFR1c6EKo1L2vnAbMGTlHnP1khhB6Ga kR/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=jx5D2mTV+ExxV8ji9PCBz7vQf+NrUEKj5YJ/dsZ+EGc=; b=0BRxucTqf2uKCbmuyVYZL+hisFWX7xtruY7KBz14i0yCLN5H8G50LyeZ+s9j/ZeU6o afHfeL8h+sHJ6SOFqa/F6HpmfZxUCjn67vg7Ys2f8hr+wtGEnB413Ke6pHQ2ox/j1kKq gIdyJRDe6ikUkk7RWrwyc45lkIodNmJC3DN01s/xKh9uR7I6rZVLwf1o/joniuDcBI3M Fhqt9DmCMWQf0GFAZr5mwP0g4ccS0siXt9QQd3PrRce/BGOdWRdce1G6osrUBFZFzNEU ehEp9pk0Yu9Hms4sZsIM32UA8FGV0G7ZLNy1AZK2d/Im22RkCDj5by+1jQXDHoF6L54+ jeOw== X-Gm-Message-State: ACgBeo3vHHN7j03kj08HDBiAVnqJFewMf4WKqf6M2S6stgXtOMW+Bl8I l3m0LwL5ai+C8dlBeV0YElJu X-Google-Smtp-Source: AA6agR7P9b6IBewqy9DpjGisAzgO74uYCSE7ZBWKK8Cwk+n3NWqNf/c1nYyvvIjanHpCkx2UCcg9ig== X-Received: by 2002:a05:6a00:842:b0:52e:2515:d657 with SMTP id q2-20020a056a00084200b0052e2515d657mr29276965pfk.31.1661344223508; Wed, 24 Aug 2022 05:30:23 -0700 (PDT) Received: from localhost.localdomain ([117.207.24.28]) by smtp.gmail.com with ESMTPSA id b3-20020a1709027e0300b00173031308fdsm3539220plm.158.2022.08.24.05.30.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Aug 2022 05:30:23 -0700 (PDT) From: Manivannan Sadhasivam To: kishon@ti.com, gregkh@linuxfoundation.org, lpieralisi@kernel.org Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, mie@igel.co.jp, kw@linux.com, Manivannan Sadhasivam , stable@vger.kernel.org Subject: [PATCH v2 1/5] misc: pci_endpoint_test: Fix the return value of IOCTL Date: Wed, 24 Aug 2022 18:00:06 +0530 Message-Id: <20220824123010.51763-2-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220824123010.51763-1-manivannan.sadhasivam@linaro.org> References: <20220824123010.51763-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" IOCTLs are supposed to return 0 for success and negative error codes for failure. Currently, this driver is returning 0 for failure and 1 for success, that's not correct. Hence, fix it! Cc: stable@vger.kernel.org #5.10 Fixes: 2c156ac71c6b ("misc: Add host side PCI driver for PCI test function = device") Signed-off-by: Manivannan Sadhasivam Reported-by: Greg Kroah-Hartman --- drivers/misc/pci_endpoint_test.c | 163 ++++++++++++++----------------- 1 file changed, 76 insertions(+), 87 deletions(-) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_t= est.c index 8f786a225dcf..a7d8ae9730f6 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -174,13 +174,12 @@ static void pci_endpoint_test_free_irq_vectors(struct= pci_endpoint_test *test) test->irq_type =3D IRQ_TYPE_UNDEFINED; } =20 -static bool pci_endpoint_test_alloc_irq_vectors(struct pci_endpoint_test *= test, +static int pci_endpoint_test_alloc_irq_vectors(struct pci_endpoint_test *t= est, int type) { - int irq =3D -1; + int irq =3D -ENOSPC; struct pci_dev *pdev =3D test->pdev; struct device *dev =3D &pdev->dev; - bool res =3D true; =20 switch (type) { case IRQ_TYPE_LEGACY: @@ -202,15 +201,16 @@ static bool pci_endpoint_test_alloc_irq_vectors(struc= t pci_endpoint_test *test, dev_err(dev, "Invalid IRQ type selected\n"); } =20 + test->irq_type =3D type; + if (irq < 0) { - irq =3D 0; - res =3D false; + test->num_irqs =3D 0; + return irq; } =20 - test->irq_type =3D type; test->num_irqs =3D irq; =20 - return res; + return 0; } =20 static void pci_endpoint_test_release_irq(struct pci_endpoint_test *test) @@ -225,7 +225,7 @@ static void pci_endpoint_test_release_irq(struct pci_en= dpoint_test *test) test->num_irqs =3D 0; } =20 -static bool pci_endpoint_test_request_irq(struct pci_endpoint_test *test) +static int pci_endpoint_test_request_irq(struct pci_endpoint_test *test) { int i; int err; @@ -240,7 +240,7 @@ static bool pci_endpoint_test_request_irq(struct pci_en= dpoint_test *test) goto fail; } =20 - return true; + return 0; =20 fail: switch (irq_type) { @@ -260,10 +260,10 @@ static bool pci_endpoint_test_request_irq(struct pci_= endpoint_test *test) break; } =20 - return false; + return err; } =20 -static bool pci_endpoint_test_bar(struct pci_endpoint_test *test, +static int pci_endpoint_test_bar(struct pci_endpoint_test *test, enum pci_barno barno) { int j; @@ -272,7 +272,7 @@ static bool pci_endpoint_test_bar(struct pci_endpoint_t= est *test, struct pci_dev *pdev =3D test->pdev; =20 if (!test->bar[barno]) - return false; + return -ENOMEM; =20 size =3D pci_resource_len(pdev, barno); =20 @@ -285,13 +285,13 @@ static bool pci_endpoint_test_bar(struct pci_endpoint= _test *test, for (j =3D 0; j < size; j +=3D 4) { val =3D pci_endpoint_test_bar_readl(test, barno, j); if (val !=3D 0xA0A0A0A0) - return false; + return -EIO; } =20 - return true; + return 0; } =20 -static bool pci_endpoint_test_legacy_irq(struct pci_endpoint_test *test) +static int pci_endpoint_test_legacy_irq(struct pci_endpoint_test *test) { u32 val; =20 @@ -303,12 +303,12 @@ static bool pci_endpoint_test_legacy_irq(struct pci_e= ndpoint_test *test) val =3D wait_for_completion_timeout(&test->irq_raised, msecs_to_jiffies(1000)); if (!val) - return false; + return -ETIMEDOUT; =20 - return true; + return 0; } =20 -static bool pci_endpoint_test_msi_irq(struct pci_endpoint_test *test, +static int pci_endpoint_test_msi_irq(struct pci_endpoint_test *test, u16 msi_num, bool msix) { u32 val; @@ -324,19 +324,18 @@ static bool pci_endpoint_test_msi_irq(struct pci_endp= oint_test *test, val =3D wait_for_completion_timeout(&test->irq_raised, msecs_to_jiffies(1000)); if (!val) - return false; + return -ETIMEDOUT; =20 - if (pci_irq_vector(pdev, msi_num - 1) =3D=3D test->last_irq) - return true; + if (pci_irq_vector(pdev, msi_num - 1) !=3D test->last_irq) + return -EIO; =20 - return false; + return 0; } =20 -static bool pci_endpoint_test_copy(struct pci_endpoint_test *test, +static int pci_endpoint_test_copy(struct pci_endpoint_test *test, unsigned long arg) { struct pci_endpoint_test_xfer_param param; - bool ret =3D false; void *src_addr; void *dst_addr; u32 flags =3D 0; @@ -360,12 +359,12 @@ static bool pci_endpoint_test_copy(struct pci_endpoin= t_test *test, err =3D copy_from_user(¶m, (void __user *)arg, sizeof(param)); if (err) { dev_err(dev, "Failed to get transfer param\n"); - return false; + return -EFAULT; } =20 size =3D param.size; if (size > SIZE_MAX - alignment) - goto err; + return -EINVAL; =20 use_dma =3D !!(param.flags & PCITEST_FLAGS_USE_DMA); if (use_dma) @@ -373,22 +372,21 @@ static bool pci_endpoint_test_copy(struct pci_endpoin= t_test *test, =20 if (irq_type < IRQ_TYPE_LEGACY || irq_type > IRQ_TYPE_MSIX) { dev_err(dev, "Invalid IRQ type option\n"); - goto err; + return -EINVAL; } =20 orig_src_addr =3D kzalloc(size + alignment, GFP_KERNEL); if (!orig_src_addr) { dev_err(dev, "Failed to allocate source buffer\n"); - ret =3D false; - goto err; + return -ENOMEM; } =20 get_random_bytes(orig_src_addr, size + alignment); orig_src_phys_addr =3D dma_map_single(dev, orig_src_addr, size + alignment, DMA_TO_DEVICE); - if (dma_mapping_error(dev, orig_src_phys_addr)) { + err =3D dma_mapping_error(dev, orig_src_phys_addr); + if (err) { dev_err(dev, "failed to map source buffer address\n"); - ret =3D false; goto err_src_phys_addr; } =20 @@ -412,15 +410,15 @@ static bool pci_endpoint_test_copy(struct pci_endpoin= t_test *test, orig_dst_addr =3D kzalloc(size + alignment, GFP_KERNEL); if (!orig_dst_addr) { dev_err(dev, "Failed to allocate destination address\n"); - ret =3D false; + err =3D -ENOMEM; goto err_dst_addr; } =20 orig_dst_phys_addr =3D dma_map_single(dev, orig_dst_addr, size + alignment, DMA_FROM_DEVICE); - if (dma_mapping_error(dev, orig_dst_phys_addr)) { + err =3D dma_mapping_error(dev, orig_dst_phys_addr); + if (err) { dev_err(dev, "failed to map destination buffer address\n"); - ret =3D false; goto err_dst_phys_addr; } =20 @@ -453,8 +451,8 @@ static bool pci_endpoint_test_copy(struct pci_endpoint_= test *test, DMA_FROM_DEVICE); =20 dst_crc32 =3D crc32_le(~0, dst_addr, size); - if (dst_crc32 =3D=3D src_crc32) - ret =3D true; + if (dst_crc32 !=3D src_crc32) + err =3D -EIO; =20 err_dst_phys_addr: kfree(orig_dst_addr); @@ -465,16 +463,13 @@ static bool pci_endpoint_test_copy(struct pci_endpoin= t_test *test, =20 err_src_phys_addr: kfree(orig_src_addr); - -err: - return ret; + return err; } =20 -static bool pci_endpoint_test_write(struct pci_endpoint_test *test, +static int pci_endpoint_test_write(struct pci_endpoint_test *test, unsigned long arg) { struct pci_endpoint_test_xfer_param param; - bool ret =3D false; u32 flags =3D 0; bool use_dma; u32 reg; @@ -492,14 +487,14 @@ static bool pci_endpoint_test_write(struct pci_endpoi= nt_test *test, int err; =20 err =3D copy_from_user(¶m, (void __user *)arg, sizeof(param)); - if (err !=3D 0) { + if (err) { dev_err(dev, "Failed to get transfer param\n"); - return false; + return -EFAULT; } =20 size =3D param.size; if (size > SIZE_MAX - alignment) - goto err; + return -EINVAL; =20 use_dma =3D !!(param.flags & PCITEST_FLAGS_USE_DMA); if (use_dma) @@ -507,23 +502,22 @@ static bool pci_endpoint_test_write(struct pci_endpoi= nt_test *test, =20 if (irq_type < IRQ_TYPE_LEGACY || irq_type > IRQ_TYPE_MSIX) { dev_err(dev, "Invalid IRQ type option\n"); - goto err; + return -EINVAL; } =20 orig_addr =3D kzalloc(size + alignment, GFP_KERNEL); if (!orig_addr) { dev_err(dev, "Failed to allocate address\n"); - ret =3D false; - goto err; + return -ENOMEM; } =20 get_random_bytes(orig_addr, size + alignment); =20 orig_phys_addr =3D dma_map_single(dev, orig_addr, size + alignment, DMA_TO_DEVICE); - if (dma_mapping_error(dev, orig_phys_addr)) { + err =3D dma_mapping_error(dev, orig_phys_addr); + if (err) { dev_err(dev, "failed to map source buffer address\n"); - ret =3D false; goto err_phys_addr; } =20 @@ -556,24 +550,21 @@ static bool pci_endpoint_test_write(struct pci_endpoi= nt_test *test, wait_for_completion(&test->irq_raised); =20 reg =3D pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_STATUS); - if (reg & STATUS_READ_SUCCESS) - ret =3D true; + if (!(reg & STATUS_READ_SUCCESS)) + err =3D -EIO; =20 dma_unmap_single(dev, orig_phys_addr, size + alignment, DMA_TO_DEVICE); =20 err_phys_addr: kfree(orig_addr); - -err: - return ret; + return err; } =20 -static bool pci_endpoint_test_read(struct pci_endpoint_test *test, +static int pci_endpoint_test_read(struct pci_endpoint_test *test, unsigned long arg) { struct pci_endpoint_test_xfer_param param; - bool ret =3D false; u32 flags =3D 0; bool use_dma; size_t size; @@ -592,12 +583,12 @@ static bool pci_endpoint_test_read(struct pci_endpoin= t_test *test, err =3D copy_from_user(¶m, (void __user *)arg, sizeof(param)); if (err) { dev_err(dev, "Failed to get transfer param\n"); - return false; + return -EFAULT; } =20 size =3D param.size; if (size > SIZE_MAX - alignment) - goto err; + return -EINVAL; =20 use_dma =3D !!(param.flags & PCITEST_FLAGS_USE_DMA); if (use_dma) @@ -605,21 +596,20 @@ static bool pci_endpoint_test_read(struct pci_endpoin= t_test *test, =20 if (irq_type < IRQ_TYPE_LEGACY || irq_type > IRQ_TYPE_MSIX) { dev_err(dev, "Invalid IRQ type option\n"); - goto err; + return -EINVAL; } =20 orig_addr =3D kzalloc(size + alignment, GFP_KERNEL); if (!orig_addr) { dev_err(dev, "Failed to allocate destination address\n"); - ret =3D false; - goto err; + return -ENOMEM; } =20 orig_phys_addr =3D dma_map_single(dev, orig_addr, size + alignment, DMA_FROM_DEVICE); - if (dma_mapping_error(dev, orig_phys_addr)) { + err =3D dma_mapping_error(dev, orig_phys_addr); + if (err) { dev_err(dev, "failed to map source buffer address\n"); - ret =3D false; goto err_phys_addr; } =20 @@ -651,50 +641,51 @@ static bool pci_endpoint_test_read(struct pci_endpoin= t_test *test, DMA_FROM_DEVICE); =20 crc32 =3D crc32_le(~0, addr, size); - if (crc32 =3D=3D pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_CHECKSUM= )) - ret =3D true; + if (crc32 !=3D pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_CHECKSUM)) + err =3D -EIO; =20 err_phys_addr: kfree(orig_addr); -err: - return ret; + return err; } =20 -static bool pci_endpoint_test_clear_irq(struct pci_endpoint_test *test) +static int pci_endpoint_test_clear_irq(struct pci_endpoint_test *test) { pci_endpoint_test_release_irq(test); pci_endpoint_test_free_irq_vectors(test); - return true; + + return 0; } =20 -static bool pci_endpoint_test_set_irq(struct pci_endpoint_test *test, +static int pci_endpoint_test_set_irq(struct pci_endpoint_test *test, int req_irq_type) { struct pci_dev *pdev =3D test->pdev; struct device *dev =3D &pdev->dev; + int err; =20 if (req_irq_type < IRQ_TYPE_LEGACY || req_irq_type > IRQ_TYPE_MSIX) { dev_err(dev, "Invalid IRQ type option\n"); - return false; + return -EINVAL; } =20 if (test->irq_type =3D=3D req_irq_type) - return true; + return 0; =20 pci_endpoint_test_release_irq(test); pci_endpoint_test_free_irq_vectors(test); =20 - if (!pci_endpoint_test_alloc_irq_vectors(test, req_irq_type)) - goto err; - - if (!pci_endpoint_test_request_irq(test)) - goto err; + err =3D pci_endpoint_test_alloc_irq_vectors(test, req_irq_type); + if (err) + return err; =20 - return true; + err =3D pci_endpoint_test_request_irq(test); + if (err) { + pci_endpoint_test_free_irq_vectors(test); + return err; + } =20 -err: - pci_endpoint_test_free_irq_vectors(test); - return false; + return 0; } =20 static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd, @@ -812,10 +803,9 @@ static int pci_endpoint_test_probe(struct pci_dev *pde= v, =20 pci_set_master(pdev); =20 - if (!pci_endpoint_test_alloc_irq_vectors(test, irq_type)) { - err =3D -EINVAL; + err =3D pci_endpoint_test_alloc_irq_vectors(test, irq_type); + if (err) goto err_disable_irq; - } =20 for (bar =3D 0; bar < PCI_STD_NUM_BARS; bar++) { if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) { @@ -852,10 +842,9 @@ static int pci_endpoint_test_probe(struct pci_dev *pde= v, goto err_ida_remove; } =20 - if (!pci_endpoint_test_request_irq(test)) { - err =3D -EINVAL; + err =3D pci_endpoint_test_request_irq(test); + if (err) goto err_kfree_test_name; - } =20 misc_device =3D &test->miscdev; misc_device->minor =3D MISC_DYNAMIC_MINOR; --=20 2.25.1 From nobody Wed Apr 8 01:39:18 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32BA5C32796 for ; Wed, 24 Aug 2022 12:30:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237529AbiHXMak (ORCPT ); Wed, 24 Aug 2022 08:30:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237508AbiHXMa3 (ORCPT ); Wed, 24 Aug 2022 08:30:29 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A2F949B58 for ; Wed, 24 Aug 2022 05:30:28 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id bf22so16863816pjb.4 for ; Wed, 24 Aug 2022 05:30:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=MXeTFOPwaEYUnBKivNI6IIvkTRiGbL/Q2wJpJf6zbRo=; b=HQHBOY5lZpaZ+qTObtvVlZeS+Hz5VZapvG+JueRbRZDAdpGvaYCj8c8/syiQFxHkwS kVHkbTjUtEvgd+t5P7OHQKd39CRHrxnCDEE71shIBzXXimjpRJE3sOrdX3wjls23Bf3j dbaie1+5oEN2rUmiC3EN0HLElzS6rylQQq4pRPg8jhmzoIV88zduw4VhZe+0Vslu2f68 qgu33LfbfuQ+A0S4YHSWwCWmKuweh8DdKNx0/kFCxhBItfCbISadP6td2FUU+zXAAKpe EJWh3vAGs7le17ILFjUc3Q/dVU2t4HsCWE6fANFYtVqxMiiKEFMYwbo12tGNZIDxkRPx 47+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=MXeTFOPwaEYUnBKivNI6IIvkTRiGbL/Q2wJpJf6zbRo=; b=Oy24M+X70Kum1tgew8B4kmCuk3UOh88ZD07mrol6WYb4+ojhiCHqVVrXaykFAVsgXh YfAOUa/NxIOGSYPXuhfoYXoy3BaeM7slmPvPwYxZAFywODyeOq7ymZQY5cOEDJWzt/jW GCfpfDDzZ2oxyhalqxknCXyYU7YpJxuQ/kKLp/Q0T7wpqrcSdlKs60+70q4Zx5dY0SP1 DlJzkShFMSQRtZew1lGZkwrUkloNtb18/2H1QYbH3gMBmLHSVGML/jj8+o6ItyzkpJg4 C/kfLPvB/xPV3Vyr6bomc5YdaPGtRHyWnz1N47UmILXWRXIW8mQSJbwp3h7fGE3sPxO/ /TQg== X-Gm-Message-State: ACgBeo2BPY7E83EZOLRFWLwLJ+quI4gDTy+WaIhdeKNjObTg5EM2sZk5 xvNyrQB0utVdBPZICsBHDr1n X-Google-Smtp-Source: AA6agR6x9GSi2J9BABOsuQCyB8ynh29Q1qxfh7AhFPTdGC0DNCf+hHeDlhOUt8BK0F2Wu0IjKfJxSw== X-Received: by 2002:a17:90b:1b10:b0:1fb:7baa:ce1c with SMTP id nu16-20020a17090b1b1000b001fb7baace1cmr4015390pjb.131.1661344227690; Wed, 24 Aug 2022 05:30:27 -0700 (PDT) Received: from localhost.localdomain ([117.207.24.28]) by smtp.gmail.com with ESMTPSA id b3-20020a1709027e0300b00173031308fdsm3539220plm.158.2022.08.24.05.30.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Aug 2022 05:30:27 -0700 (PDT) From: Manivannan Sadhasivam To: kishon@ti.com, gregkh@linuxfoundation.org, lpieralisi@kernel.org Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, mie@igel.co.jp, kw@linux.com, Manivannan Sadhasivam , stable@vger.kernel.org Subject: [PATCH v2 2/5] tools: PCI: Fix parsing the return value of IOCTLs Date: Wed, 24 Aug 2022 18:00:07 +0530 Message-Id: <20220824123010.51763-3-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220824123010.51763-1-manivannan.sadhasivam@linaro.org> References: <20220824123010.51763-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" "pci_endpoint_test" driver now returns 0 for success and negative error code for failure. So adapt to the change by reporting FAILURE if the return value is < 0, and SUCCESS otherwise. Cc: stable@vger.kernel.org #5.10 Fixes: 3f2ed8134834 ("tools: PCI: Add a userspace tool to test PCI endpoint= ") Signed-off-by: Manivannan Sadhasivam --- tools/pci/pcitest.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/tools/pci/pcitest.c b/tools/pci/pcitest.c index 441b54234635..a4e5b17cc3b5 100644 --- a/tools/pci/pcitest.c +++ b/tools/pci/pcitest.c @@ -18,7 +18,6 @@ =20 #define BILLION 1E9 =20 -static char *result[] =3D { "NOT OKAY", "OKAY" }; static char *irq[] =3D { "LEGACY", "MSI", "MSI-X" }; =20 struct pci_test { @@ -54,9 +53,9 @@ static int run_test(struct pci_test *test) ret =3D ioctl(fd, PCITEST_BAR, test->barnum); fprintf(stdout, "BAR%d:\t\t", test->barnum); if (ret < 0) - fprintf(stdout, "TEST FAILED\n"); + fprintf(stdout, "FAILED\n"); else - fprintf(stdout, "%s\n", result[ret]); + fprintf(stdout, "SUCCESS\n"); } =20 if (test->set_irqtype) { @@ -65,16 +64,18 @@ static int run_test(struct pci_test *test) if (ret < 0) fprintf(stdout, "FAILED\n"); else - fprintf(stdout, "%s\n", result[ret]); + fprintf(stdout, "SUCCESS\n"); } =20 if (test->get_irqtype) { ret =3D ioctl(fd, PCITEST_GET_IRQTYPE); fprintf(stdout, "GET IRQ TYPE:\t\t"); - if (ret < 0) + if (ret < 0) { fprintf(stdout, "FAILED\n"); - else + } else { fprintf(stdout, "%s\n", irq[ret]); + ret =3D 0; + } } =20 if (test->clear_irq) { @@ -83,34 +84,34 @@ static int run_test(struct pci_test *test) if (ret < 0) fprintf(stdout, "FAILED\n"); else - fprintf(stdout, "%s\n", result[ret]); + fprintf(stdout, "SUCCESS\n"); } =20 if (test->legacyirq) { ret =3D ioctl(fd, PCITEST_LEGACY_IRQ, 0); fprintf(stdout, "LEGACY IRQ:\t"); if (ret < 0) - fprintf(stdout, "TEST FAILED\n"); + fprintf(stdout, "FAILED\n"); else - fprintf(stdout, "%s\n", result[ret]); + fprintf(stdout, "SUCCESS\n"); } =20 if (test->msinum > 0 && test->msinum <=3D 32) { ret =3D ioctl(fd, PCITEST_MSI, test->msinum); fprintf(stdout, "MSI%d:\t\t", test->msinum); if (ret < 0) - fprintf(stdout, "TEST FAILED\n"); + fprintf(stdout, "FAILED\n"); else - fprintf(stdout, "%s\n", result[ret]); + fprintf(stdout, "SUCCESS\n"); } =20 if (test->msixnum > 0 && test->msixnum <=3D 2048) { ret =3D ioctl(fd, PCITEST_MSIX, test->msixnum); fprintf(stdout, "MSI-X%d:\t\t", test->msixnum); if (ret < 0) - fprintf(stdout, "TEST FAILED\n"); + fprintf(stdout, "FAILED\n"); else - fprintf(stdout, "%s\n", result[ret]); + fprintf(stdout, "SUCCESS\n"); } =20 if (test->write) { @@ -120,9 +121,9 @@ static int run_test(struct pci_test *test) ret =3D ioctl(fd, PCITEST_WRITE, ¶m); fprintf(stdout, "WRITE (%7ld bytes):\t\t", test->size); if (ret < 0) - fprintf(stdout, "TEST FAILED\n"); + fprintf(stdout, "FAILED\n"); else - fprintf(stdout, "%s\n", result[ret]); + fprintf(stdout, "SUCCESS\n"); } =20 if (test->read) { @@ -132,9 +133,9 @@ static int run_test(struct pci_test *test) ret =3D ioctl(fd, PCITEST_READ, ¶m); fprintf(stdout, "READ (%7ld bytes):\t\t", test->size); if (ret < 0) - fprintf(stdout, "TEST FAILED\n"); + fprintf(stdout, "FAILED\n"); else - fprintf(stdout, "%s\n", result[ret]); + fprintf(stdout, "SUCCESS\n"); } =20 if (test->copy) { @@ -144,14 +145,14 @@ static int run_test(struct pci_test *test) ret =3D ioctl(fd, PCITEST_COPY, ¶m); fprintf(stdout, "COPY (%7ld bytes):\t\t", test->size); if (ret < 0) - fprintf(stdout, "TEST FAILED\n"); + fprintf(stdout, "FAILED\n"); else - fprintf(stdout, "%s\n", result[ret]); + fprintf(stdout, "SUCCESS\n"); } =20 fflush(stdout); close(fd); - return (ret < 0) ? ret : 1 - ret; /* return 0 if test succeeded */ + return ret; } =20 int main(int argc, char **argv) --=20 2.25.1 From nobody Wed Apr 8 01:39:18 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F029C00140 for ; Wed, 24 Aug 2022 12:31:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237557AbiHXMap (ORCPT ); Wed, 24 Aug 2022 08:30:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237479AbiHXMad (ORCPT ); Wed, 24 Aug 2022 08:30:33 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7979F4D178 for ; Wed, 24 Aug 2022 05:30:32 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id s36-20020a17090a69a700b001faad0a7a34so1428347pjj.4 for ; Wed, 24 Aug 2022 05:30:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=u8y/r/XRzUdXpFeOgWGRlYtl7JW+XG3qjD2H5X3t6VU=; b=xoMLQ/pbCct2ail+mi5yAKNNxllhIFJ4jLnUZilIT1gXuHDI7VlCvxuidcviokMLCL BpyH8EShKjQ/+Nz3eoMlu3ZxxqIIgo15Ontekj3/eHu2xinMuZQT8T7O9NQCuBie9QY2 PthruMNGFkU8zkLGyQVxqjAvTOL9a3dRFQJUWInOojPWVjpFXx1/TP+/AeXu4cXXuV7f 5J5MQlICHS3GgpHZN29vNN9q3aHf61FE5S6+X168CrtyittLFP8XfAfXJ29/+iT48JHR khvdauqIZfKb8mBhLJMpQVnEsdLBBspTJ0X/EivsfG70LoD/QkuY6bpaZtAx8WAwl3Jc Ar1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=u8y/r/XRzUdXpFeOgWGRlYtl7JW+XG3qjD2H5X3t6VU=; b=X9y/ar+d/iP3qw51CqBQq7lVfjF1EZ/c4NVLwyyzdRG25Q4/ev8PuXJ3//fy9kNhbi IeNhiNXcXzw5LrGflZ4ZiTCyrXdXYxCD3cpu65Fh1vdsWupcQmsHparQ1VO6P/2PuYK7 vboFacbdZGeodQuYYglJTRX6MmKA/BmRaVtarJQ84Fgb/EPWRp+zBl21hhsAOdL4Y/Zo 0AeAh8f/7J3P/MsxFZaPcq9AyR6K+TA6QLnoYfolG/HUEUH3sc5uOCPSApcw/suQbsWF d6I0Bb6CXXnJPB8fspV4y4jsfeP+0w+c9l0X/wv/8bqYqWmJ9N4W6ZiGQWf3iH1tHdOz L+aw== X-Gm-Message-State: ACgBeo2EhENnoia4tLg5grNSZPagRRVWdSeOzu6xRaLFG+wVfL4IXN4a 0a0YQ++alGKLN6atPRcVocQhH9nhAfG3 X-Google-Smtp-Source: AA6agR5lbQb07q07y2DyrSsy/8lWjg7mGKNQL+ZYzktgLJ385BIgC8leoq3f8ciKsvVmcjFupnMCxg== X-Received: by 2002:a17:902:ebc8:b0:172:549d:e392 with SMTP id p8-20020a170902ebc800b00172549de392mr28527048plg.141.1661344231883; Wed, 24 Aug 2022 05:30:31 -0700 (PDT) Received: from localhost.localdomain ([117.207.24.28]) by smtp.gmail.com with ESMTPSA id b3-20020a1709027e0300b00173031308fdsm3539220plm.158.2022.08.24.05.30.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Aug 2022 05:30:31 -0700 (PDT) From: Manivannan Sadhasivam To: kishon@ti.com, gregkh@linuxfoundation.org, lpieralisi@kernel.org Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, mie@igel.co.jp, kw@linux.com, Manivannan Sadhasivam , stable@vger.kernel.org Subject: [PATCH v2 3/5] Documentation: PCI: endpoint: Use the correct return value of pcitest.sh Date: Wed, 24 Aug 2022 18:00:08 +0530 Message-Id: <20220824123010.51763-4-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220824123010.51763-1-manivannan.sadhasivam@linaro.org> References: <20220824123010.51763-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The pci_endpoint_test driver has been fixed to return correct error no from IOCTL. In that process, the pcitest tool now returns SUCCESS and FAILED instead of OKAY and NOT_OKAY. So change that in documentation also. Cc: stable@vger.kernel.org #5.10 Fixes: 16263d9e1ded ("Documentation: PCI: Add userguide for PCI endpoint te= st function") Signed-off-by: Manivannan Sadhasivam --- Documentation/PCI/endpoint/pci-test-howto.rst | 152 +++++++++--------- 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/Documentation/PCI/endpoint/pci-test-howto.rst b/Documentation/= PCI/endpoint/pci-test-howto.rst index 909f770a07d6..3bc43b9f9856 100644 --- a/Documentation/PCI/endpoint/pci-test-howto.rst +++ b/Documentation/PCI/endpoint/pci-test-howto.rst @@ -144,92 +144,92 @@ pcitest.sh Output # pcitest.sh BAR tests =20 - BAR0: OKAY - BAR1: OKAY - BAR2: OKAY - BAR3: OKAY - BAR4: NOT OKAY - BAR5: NOT OKAY + BAR0: SUCCESS + BAR1: SUCCESS + BAR2: SUCCESS + BAR3: SUCCESS + BAR4: FAILED + BAR5: FAILED =20 Interrupt tests =20 - SET IRQ TYPE TO LEGACY: OKAY - LEGACY IRQ: NOT OKAY - SET IRQ TYPE TO MSI: OKAY - MSI1: OKAY - MSI2: OKAY - MSI3: OKAY - MSI4: OKAY - MSI5: OKAY - MSI6: OKAY - MSI7: OKAY - MSI8: OKAY - MSI9: OKAY - MSI10: OKAY - MSI11: OKAY - MSI12: OKAY - MSI13: OKAY - MSI14: OKAY - MSI15: OKAY - MSI16: OKAY - MSI17: NOT OKAY - MSI18: NOT OKAY - MSI19: NOT OKAY - MSI20: NOT OKAY - MSI21: NOT OKAY - MSI22: NOT OKAY - MSI23: NOT OKAY - MSI24: NOT OKAY - MSI25: NOT OKAY - MSI26: NOT OKAY - MSI27: NOT OKAY - MSI28: NOT OKAY - MSI29: NOT OKAY - MSI30: NOT OKAY - MSI31: NOT OKAY - MSI32: NOT OKAY - SET IRQ TYPE TO MSI-X: OKAY - MSI-X1: OKAY - MSI-X2: OKAY - MSI-X3: OKAY - MSI-X4: OKAY - MSI-X5: OKAY - MSI-X6: OKAY - MSI-X7: OKAY - MSI-X8: OKAY - MSI-X9: NOT OKAY - MSI-X10: NOT OKAY - MSI-X11: NOT OKAY - MSI-X12: NOT OKAY - MSI-X13: NOT OKAY - MSI-X14: NOT OKAY - MSI-X15: NOT OKAY - MSI-X16: NOT OKAY + SET IRQ TYPE TO LEGACY: SUCCESS + LEGACY IRQ: FAILED + SET IRQ TYPE TO MSI: SUCCESS + MSI1: SUCCESS + MSI2: SUCCESS + MSI3: SUCCESS + MSI4: SUCCESS + MSI5: SUCCESS + MSI6: SUCCESS + MSI7: SUCCESS + MSI8: SUCCESS + MSI9: SUCCESS + MSI10: SUCCESS + MSI11: SUCCESS + MSI12: SUCCESS + MSI13: SUCCESS + MSI14: SUCCESS + MSI15: SUCCESS + MSI16: SUCCESS + MSI17: FAILED + MSI18: FAILED + MSI19: FAILED + MSI20: FAILED + MSI21: FAILED + MSI22: FAILED + MSI23: FAILED + MSI24: FAILED + MSI25: FAILED + MSI26: FAILED + MSI27: FAILED + MSI28: FAILED + MSI29: FAILED + MSI30: FAILED + MSI31: FAILED + MSI32: FAILED + SET IRQ TYPE TO MSI-X: SUCCESS + MSI-X1: SUCCESS + MSI-X2: SUCCESS + MSI-X3: SUCCESS + MSI-X4: SUCCESS + MSI-X5: SUCCESS + MSI-X6: SUCCESS + MSI-X7: SUCCESS + MSI-X8: SUCCESS + MSI-X9: FAILED + MSI-X10: FAILED + MSI-X11: FAILED + MSI-X12: FAILED + MSI-X13: FAILED + MSI-X14: FAILED + MSI-X15: FAILED + MSI-X16: FAILED [...] - MSI-X2047: NOT OKAY - MSI-X2048: NOT OKAY + MSI-X2047: FAILED + MSI-X2048: FAILED =20 Read Tests =20 - SET IRQ TYPE TO MSI: OKAY - READ ( 1 bytes): OKAY - READ ( 1024 bytes): OKAY - READ ( 1025 bytes): OKAY - READ (1024000 bytes): OKAY - READ (1024001 bytes): OKAY + SET IRQ TYPE TO MSI: SUCCESS + READ ( 1 bytes): SUCCESS + READ ( 1024 bytes): SUCCESS + READ ( 1025 bytes): SUCCESS + READ (1024000 bytes): SUCCESS + READ (1024001 bytes): SUCCESS =20 Write Tests =20 - WRITE ( 1 bytes): OKAY - WRITE ( 1024 bytes): OKAY - WRITE ( 1025 bytes): OKAY - WRITE (1024000 bytes): OKAY - WRITE (1024001 bytes): OKAY + WRITE ( 1 bytes): SUCCESS + WRITE ( 1024 bytes): SUCCESS + WRITE ( 1025 bytes): SUCCESS + WRITE (1024000 bytes): SUCCESS + WRITE (1024001 bytes): SUCCESS =20 Copy Tests =20 - COPY ( 1 bytes): OKAY - COPY ( 1024 bytes): OKAY - COPY ( 1025 bytes): OKAY - COPY (1024000 bytes): OKAY - COPY (1024001 bytes): OKAY + COPY ( 1 bytes): SUCCESS + COPY ( 1024 bytes): SUCCESS + COPY ( 1025 bytes): SUCCESS + COPY (1024000 bytes): SUCCESS + COPY (1024001 bytes): SUCCESS --=20 2.25.1 From nobody Wed Apr 8 01:39:18 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 104FDC00140 for ; Wed, 24 Aug 2022 12:30:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237626AbiHXMar (ORCPT ); Wed, 24 Aug 2022 08:30:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236586AbiHXMag (ORCPT ); Wed, 24 Aug 2022 08:30:36 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E494615A1D for ; Wed, 24 Aug 2022 05:30:35 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id g18so16915614pju.0 for ; Wed, 24 Aug 2022 05:30:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=FDm84dyy75ENZ0IrYEJTEobHEymiTqy3rBmHZuIhj6A=; b=ltGAr6JpF5rXO3b+Wn9cL3fNxmpSKzik53UOFwkssxyTQZYyZsBJsI7PSdbVf2yu6l y7NfphDA+xbrJMBiJcOEDF/Rr3EGkfrHHKNbezh2ByoAk+BYkz1NFTnFoLiV+JmIlasu kGwYx90rKcagSgnNhutP1u4fDSgFiY3TjOgHDQ2miCDEYriE7Ts8/S75u0VGUqGZO1+N 3dKlwxiysFeJNYuBsBE+qOz3ReMsW3u1aXO9tYMCqXMohx7ogiuYaikDqGfHUVbdQQsJ OuZUYRM/kcK3jFcFA8ODGgcDM4VKOmY7LIspuGIytaEp7ngzywnLhdJxFJwBfDbnApN3 YwlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=FDm84dyy75ENZ0IrYEJTEobHEymiTqy3rBmHZuIhj6A=; b=xyPgbAsa+ae/JYMh6p4sflNw+Qf3Z7Lkkh248jOlH9fz8tV6AoZ4hcCFA/w79fbwI1 4eZ1KMLnAjp9lKIc6l9nnEs8VOxCk1/l60Y7tvcvEo0F92/oSeiRsYvwFVvS+dZ+Dsyk iLOOIHudH7Tl3RDH+D8k9sgAvYxj4zN5eIPueIyXzWvBbiYqzG90ylwfsZy2IcsxE3jR cqyYauTMjN96aJZeR4B1ifJPHR6Vyzy3soRVfRwf+gElK1L6ioqEtTMtD5SNKyEPOtFc UvP6oPZPWU4Tq8p+pvIJA/ifjMEBHFKAlbpwt9SKFSUM7VTA6GiyQ0aYVtPPzX3/XDGH StmQ== X-Gm-Message-State: ACgBeo2uWAhJz654JgIDbBYxs6gtX9aS7RVQjr6Y4lFdQ4AmGD92BWhL WRj7pUE5mxYz1ZDwEBQQ2A5f X-Google-Smtp-Source: AA6agR4gBzmuGb87Azs89AknZIhwzdo+ke4N5E/7y/nF0rubNHOj6n+ye8BpQGQFAcIQ+I+hV2FceQ== X-Received: by 2002:a17:90a:8b82:b0:1fa:973c:1d34 with SMTP id z2-20020a17090a8b8200b001fa973c1d34mr8181609pjn.31.1661344235395; Wed, 24 Aug 2022 05:30:35 -0700 (PDT) Received: from localhost.localdomain ([117.207.24.28]) by smtp.gmail.com with ESMTPSA id b3-20020a1709027e0300b00173031308fdsm3539220plm.158.2022.08.24.05.30.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Aug 2022 05:30:35 -0700 (PDT) From: Manivannan Sadhasivam To: kishon@ti.com, gregkh@linuxfoundation.org, lpieralisi@kernel.org Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, mie@igel.co.jp, kw@linux.com, Manivannan Sadhasivam Subject: [PATCH v2 4/5] misc: pci_endpoint_test: Remove unnecessary WARN_ON Date: Wed, 24 Aug 2022 18:00:09 +0530 Message-Id: <20220824123010.51763-5-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220824123010.51763-1-manivannan.sadhasivam@linaro.org> References: <20220824123010.51763-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" If unable to map test_reg_bar, then probe will fail with a dedicated error message. So there is no real need of WARN_ON here. Signed-off-by: Manivannan Sadhasivam --- drivers/misc/pci_endpoint_test.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_t= est.c index a7d8ae9730f6..5e4d4691a160 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -810,10 +810,8 @@ static int pci_endpoint_test_probe(struct pci_dev *pde= v, for (bar =3D 0; bar < PCI_STD_NUM_BARS; bar++) { if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) { base =3D pci_ioremap_bar(pdev, bar); - if (!base) { + if (!base) dev_err(dev, "Failed to read BAR%d\n", bar); - WARN_ON(bar =3D=3D test_reg_bar); - } test->bar[bar] =3D base; } } --=20 2.25.1 From nobody Wed Apr 8 01:39:18 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4652DC32793 for ; Wed, 24 Aug 2022 12:31:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237664AbiHXMbX (ORCPT ); Wed, 24 Aug 2022 08:31:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237570AbiHXMaq (ORCPT ); Wed, 24 Aug 2022 08:30:46 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 454265E645 for ; Wed, 24 Aug 2022 05:30:39 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id c13-20020a17090a4d0d00b001fb6921b42aso1319955pjg.2 for ; Wed, 24 Aug 2022 05:30:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=uAW+kjtQa+80IfCy6IL5kC5fYW/7yUQfz0e6h9eDx6U=; b=sg+4drdGaUY0LXCOCdgTnN/ZEnFNJJMEUKPl/nG8dXzi/wXDo0Cy9Qcs0OZWYXWujr ANjd3KDHuAwF03KxA/R0ZkrhVe8EJskcMxn217hk4RFVNkwcRaf2i3OMk71GWXrBC7GI tAjBBv5Uf4jQoopGGauAR7XBmBY9loYhnvKpqTYh4lJSWMqJONSmQAu3MCF2oXI9U3Ma E3MT1K7nrp3gAK6js2fYyPaK5gLHjhL1NDXs1NGry2v5B6MuS2bQNJdeFV7ol4c8yDnx xhYT/BqjxBvf0ttvlVkMIAOs+okRT3NOO+K9dqu33H/a5XttQLO14caGiIfzJegCfVha aD9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=uAW+kjtQa+80IfCy6IL5kC5fYW/7yUQfz0e6h9eDx6U=; b=rMr9ElUGwL5pI/g6nNhJHDTLj8Q/f2P47T9x3Nb5aPHIs3BkLJlc7P0jSmw9Ph8kcz jH1JD+eMDocEDI0AQSwLGY8FMNaALcfHrHTg1tzUC5dc0msQJ3RFhY38OWUI5DRgUJte 32Y6yJeSJcsx6M7n6PkcAAngUKgdHj1Fe5vWR2MDMs8eT0ri5Fw8Q0uBCjkicNIaxw1j ZICqiab0/qrf9HE8WS08g9sv0qgIEmTU82tiLSz49WeOFba+whVoOIeiyNRptS+gLcdO uk28HRw9EbUfi7fk2cNYJ5nfnudVEprnkKwGeQmLKMjKzvFEWtqp706/obkHDYDCErdC NOSw== X-Gm-Message-State: ACgBeo0mHyonisbYcR5W4Thwpsvj2lOh9c4UQZMcSaizCB3P20981rvf cpn7bwqD31EygmxXpxOpV1P1 X-Google-Smtp-Source: AA6agR5czQel5mWzZi3n+4qNkTWGh/vvxmu8AqiAYTsY5T9G0kG5EozYuvL3RIFF7LCc1/tkLt0KNg== X-Received: by 2002:a17:90b:1d10:b0:1fb:e7b:270f with SMTP id on16-20020a17090b1d1000b001fb0e7b270fmr8180054pjb.192.1661344238634; Wed, 24 Aug 2022 05:30:38 -0700 (PDT) Received: from localhost.localdomain ([117.207.24.28]) by smtp.gmail.com with ESMTPSA id b3-20020a1709027e0300b00173031308fdsm3539220plm.158.2022.08.24.05.30.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Aug 2022 05:30:38 -0700 (PDT) From: Manivannan Sadhasivam To: kishon@ti.com, gregkh@linuxfoundation.org, lpieralisi@kernel.org Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, mie@igel.co.jp, kw@linux.com, Manivannan Sadhasivam Subject: [PATCH v2 5/5] tools: PCI: Fix memory leak Date: Wed, 24 Aug 2022 18:00:10 +0530 Message-Id: <20220824123010.51763-6-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220824123010.51763-1-manivannan.sadhasivam@linaro.org> References: <20220824123010.51763-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Memory allocated for "test" needs to be freed at the end of the main(). Fixes: 3f2ed8134834 ("tools: PCI: Add a userspace tool to test PCI endpoint= ") Signed-off-by: Manivannan Sadhasivam --- tools/pci/pcitest.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/pci/pcitest.c b/tools/pci/pcitest.c index a4e5b17cc3b5..a416a66802f3 100644 --- a/tools/pci/pcitest.c +++ b/tools/pci/pcitest.c @@ -157,7 +157,7 @@ static int run_test(struct pci_test *test) =20 int main(int argc, char **argv) { - int c; + int c, ret; struct pci_test *test; =20 test =3D calloc(1, sizeof(*test)); @@ -249,5 +249,8 @@ int main(int argc, char **argv) return -EINVAL; } =20 - return run_test(test); + ret =3D run_test(test); + free(test); + + return ret; } --=20 2.25.1