All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] um: make PCI emulation driver init/exit static
@ 2021-06-25  8:34 Johannes Berg
  2021-06-25  8:34 ` [PATCH 2/4] lib/logic_iomem: fix sparse warnings Johannes Berg
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Johannes Berg @ 2021-06-25  8:34 UTC (permalink / raw)
  To: linux-um; +Cc: Johannes Berg, kernel test robot

From: Johannes Berg <johannes.berg@intel.com>

The functions aren't used elsewhere, so they can be static.

Reported-by: kernel test robot <lkp@intel.com>
Fixes: 68f5d3f3b654 ("um: add PCI over virtio emulation driver")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 arch/um/drivers/virt-pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/um/drivers/virt-pci.c b/arch/um/drivers/virt-pci.c
index 0b802834f40a..70c17de16662 100644
--- a/arch/um/drivers/virt-pci.c
+++ b/arch/um/drivers/virt-pci.c
@@ -810,7 +810,7 @@ void *pci_root_bus_fwnode(struct pci_bus *bus)
 	return um_pci_fwnode;
 }
 
-int um_pci_init(void)
+static int um_pci_init(void)
 {
 	int err, i;
 
@@ -884,7 +884,7 @@ int um_pci_init(void)
 }
 module_init(um_pci_init);
 
-void um_pci_exit(void)
+static void um_pci_exit(void)
 {
 	unregister_virtio_driver(&um_pci_virtio_driver);
 	irq_domain_remove(um_pci_msi_domain);
-- 
2.31.1


_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/4] lib/logic_iomem: fix sparse warnings
  2021-06-25  8:34 [PATCH 1/4] um: make PCI emulation driver init/exit static Johannes Berg
@ 2021-06-25  8:34 ` Johannes Berg
  2021-06-25  9:16   ` Anton Ivanov
  2021-06-25  8:34 ` [PATCH 3/4] um: virtio_uml: include linux/virtio-uml.h Johannes Berg
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Johannes Berg @ 2021-06-25  8:34 UTC (permalink / raw)
  To: linux-um; +Cc: Johannes Berg, kernel test robot

From: Johannes Berg <johannes.berg@intel.com>

A couple of sparse warnings happened here due to casts on
the prints, a missing static and a missing include. Fix
all of them.

Reported-by: kernel test robot <lkp@intel.com>
Fixes: ca2e334232b6 ("lib: add iomem emulation (logic_iomem)")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 lib/logic_iomem.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/lib/logic_iomem.c b/lib/logic_iomem.c
index b76b92dd0f1f..9bdfde0c0f86 100644
--- a/lib/logic_iomem.c
+++ b/lib/logic_iomem.c
@@ -6,6 +6,7 @@
 #include <linux/types.h>
 #include <linux/slab.h>
 #include <linux/logic_iomem.h>
+#include <asm/io.h>
 
 struct logic_iomem_region {
 	const struct resource *res;
@@ -78,7 +79,7 @@ static void __iomem *real_ioremap(phys_addr_t offset, size_t size)
 static void real_iounmap(void __iomem *addr)
 {
 	WARN(1, "invalid iounmap for addr 0x%llx\n",
-	     (unsigned long long)addr);
+	     (unsigned long long __force)addr);
 }
 #endif /* CONFIG_LOGIC_IOMEM_FALLBACK */
 
@@ -172,14 +173,15 @@ EXPORT_SYMBOL(iounmap);
 static u##sz real_raw_read ## op(const volatile void __iomem *addr)	\
 {									\
 	WARN(1, "Invalid read" #op " at address %llx\n",		\
-	     (unsigned long long)addr);					\
+	     (unsigned long long __force)addr);				\
 	return (u ## sz)~0ULL;						\
 }									\
 									\
-void real_raw_write ## op(u ## sz val, volatile void __iomem *addr)	\
+static void real_raw_write ## op(u ## sz val,				\
+				 volatile void __iomem *addr)		\
 {									\
 	WARN(1, "Invalid writeq" #op " of 0x%llx at address %llx\n",	\
-	     (unsigned long long)val, (unsigned long long)addr);	\
+	     (unsigned long long)val, (unsigned long long __force)addr);\
 }									\
 
 MAKE_FALLBACK(b, 8);
@@ -192,14 +194,14 @@ MAKE_FALLBACK(q, 64);
 static void real_memset_io(volatile void __iomem *addr, int value, size_t size)
 {
 	WARN(1, "Invalid memset_io at address 0x%llx\n",
-	     (unsigned long long)addr);
+	     (unsigned long long __force)addr);
 }
 
 static void real_memcpy_fromio(void *buffer, const volatile void __iomem *addr,
 			       size_t size)
 {
 	WARN(1, "Invalid memcpy_fromio at address 0x%llx\n",
-	     (unsigned long long)addr);
+	     (unsigned long long __force)addr);
 
 	memset(buffer, 0xff, size);
 }
@@ -208,7 +210,7 @@ static void real_memcpy_toio(volatile void __iomem *addr, const void *buffer,
 			     size_t size)
 {
 	WARN(1, "Invalid memcpy_toio at address 0x%llx\n",
-	     (unsigned long long)addr);
+	     (unsigned long long __force)addr);
 }
 #endif /* CONFIG_LOGIC_IOMEM_FALLBACK */
 
-- 
2.31.1


_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/4] um: virtio_uml: include linux/virtio-uml.h
  2021-06-25  8:34 [PATCH 1/4] um: make PCI emulation driver init/exit static Johannes Berg
  2021-06-25  8:34 ` [PATCH 2/4] lib/logic_iomem: fix sparse warnings Johannes Berg
@ 2021-06-25  8:34 ` Johannes Berg
  2021-06-25  9:16   ` Anton Ivanov
  2021-06-25  8:34 ` [PATCH 4/4] um: virtio_uml: fix memory leak on init failures Johannes Berg
  2021-06-25  9:16 ` [PATCH 1/4] um: make PCI emulation driver init/exit static Anton Ivanov
  3 siblings, 1 reply; 8+ messages in thread
From: Johannes Berg @ 2021-06-25  8:34 UTC (permalink / raw)
  To: linux-um; +Cc: Johannes Berg, kernel test robot

From: Johannes Berg <johannes.berg@intel.com>

This fixes a sparse warning, since the function defined
here should have a declaration (or be static).

Reported-by: kernel test robot <lkp@intel.com>
Fixes: 43c590cb8666 ("um: virtio/pci: enable suspend/resume")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 arch/um/drivers/virtio_uml.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/um/drivers/virtio_uml.c b/arch/um/drivers/virtio_uml.c
index 4412d6febade..cb79fe33d84e 100644
--- a/arch/um/drivers/virtio_uml.c
+++ b/arch/um/drivers/virtio_uml.c
@@ -27,6 +27,7 @@
 #include <linux/virtio_config.h>
 #include <linux/virtio_ring.h>
 #include <linux/time-internal.h>
+#include <linux/virtio-uml.h>
 #include <shared/as-layout.h>
 #include <irq_kern.h>
 #include <init.h>
-- 
2.31.1


_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/4] um: virtio_uml: fix memory leak on init failures
  2021-06-25  8:34 [PATCH 1/4] um: make PCI emulation driver init/exit static Johannes Berg
  2021-06-25  8:34 ` [PATCH 2/4] lib/logic_iomem: fix sparse warnings Johannes Berg
  2021-06-25  8:34 ` [PATCH 3/4] um: virtio_uml: include linux/virtio-uml.h Johannes Berg
@ 2021-06-25  8:34 ` Johannes Berg
  2021-06-25  9:15   ` Anton Ivanov
  2021-06-25  9:16 ` [PATCH 1/4] um: make PCI emulation driver init/exit static Anton Ivanov
  3 siblings, 1 reply; 8+ messages in thread
From: Johannes Berg @ 2021-06-25  8:34 UTC (permalink / raw)
  To: linux-um; +Cc: Johannes Berg

From: Johannes Berg <johannes.berg@intel.com>

If initialization fails, e.g. because the connection failed,
we leak the 'vu_dev'. Fix that. Reported by smatch.

Fixes: 5d38f324993f ("um: drivers: Add virtio vhost-user driver")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 arch/um/drivers/virtio_uml.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/um/drivers/virtio_uml.c b/arch/um/drivers/virtio_uml.c
index cb79fe33d84e..d51e445df797 100644
--- a/arch/um/drivers/virtio_uml.c
+++ b/arch/um/drivers/virtio_uml.c
@@ -1140,7 +1140,7 @@ static int virtio_uml_probe(struct platform_device *pdev)
 		rc = os_connect_socket(pdata->socket_path);
 	} while (rc == -EINTR);
 	if (rc < 0)
-		return rc;
+		goto error_free;
 	vu_dev->sock = rc;
 
 	spin_lock_init(&vu_dev->sock_lock);
@@ -1161,6 +1161,8 @@ static int virtio_uml_probe(struct platform_device *pdev)
 
 error_init:
 	os_close_file(vu_dev->sock);
+error_free:
+	kfree(vu_dev);
 	return rc;
 }
 
-- 
2.31.1


_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 4/4] um: virtio_uml: fix memory leak on init failures
  2021-06-25  8:34 ` [PATCH 4/4] um: virtio_uml: fix memory leak on init failures Johannes Berg
@ 2021-06-25  9:15   ` Anton Ivanov
  0 siblings, 0 replies; 8+ messages in thread
From: Anton Ivanov @ 2021-06-25  9:15 UTC (permalink / raw)
  To: Johannes Berg, linux-um; +Cc: Johannes Berg



On 25/06/2021 09:34, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
> 
> If initialization fails, e.g. because the connection failed,
> we leak the 'vu_dev'. Fix that. Reported by smatch.
> 
> Fixes: 5d38f324993f ("um: drivers: Add virtio vhost-user driver")
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
> ---
>   arch/um/drivers/virtio_uml.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/um/drivers/virtio_uml.c b/arch/um/drivers/virtio_uml.c
> index cb79fe33d84e..d51e445df797 100644
> --- a/arch/um/drivers/virtio_uml.c
> +++ b/arch/um/drivers/virtio_uml.c
> @@ -1140,7 +1140,7 @@ static int virtio_uml_probe(struct platform_device *pdev)
>   		rc = os_connect_socket(pdata->socket_path);
>   	} while (rc == -EINTR);
>   	if (rc < 0)
> -		return rc;
> +		goto error_free;
>   	vu_dev->sock = rc;
>   
>   	spin_lock_init(&vu_dev->sock_lock);
> @@ -1161,6 +1161,8 @@ static int virtio_uml_probe(struct platform_device *pdev)
>   
>   error_init:
>   	os_close_file(vu_dev->sock);
> +error_free:
> +	kfree(vu_dev);
>   	return rc;
>   }
>   
> 

Acked-By: Anton Ivanov <anton.ivanov@cambridgegreys.com>

-- 
Anton R. Ivanov
https://www.kot-begemot.co.uk/

_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/4] um: virtio_uml: include linux/virtio-uml.h
  2021-06-25  8:34 ` [PATCH 3/4] um: virtio_uml: include linux/virtio-uml.h Johannes Berg
@ 2021-06-25  9:16   ` Anton Ivanov
  0 siblings, 0 replies; 8+ messages in thread
From: Anton Ivanov @ 2021-06-25  9:16 UTC (permalink / raw)
  To: Johannes Berg, linux-um; +Cc: Johannes Berg, kernel test robot



On 25/06/2021 09:34, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
> 
> This fixes a sparse warning, since the function defined
> here should have a declaration (or be static).
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Fixes: 43c590cb8666 ("um: virtio/pci: enable suspend/resume")
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
> ---
>   arch/um/drivers/virtio_uml.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/arch/um/drivers/virtio_uml.c b/arch/um/drivers/virtio_uml.c
> index 4412d6febade..cb79fe33d84e 100644
> --- a/arch/um/drivers/virtio_uml.c
> +++ b/arch/um/drivers/virtio_uml.c
> @@ -27,6 +27,7 @@
>   #include <linux/virtio_config.h>
>   #include <linux/virtio_ring.h>
>   #include <linux/time-internal.h>
> +#include <linux/virtio-uml.h>
>   #include <shared/as-layout.h>
>   #include <irq_kern.h>
>   #include <init.h>
> 
Acked-By: Anton Ivanov <anton.ivanov@cambridgegreys.com>

-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/

_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/4] lib/logic_iomem: fix sparse warnings
  2021-06-25  8:34 ` [PATCH 2/4] lib/logic_iomem: fix sparse warnings Johannes Berg
@ 2021-06-25  9:16   ` Anton Ivanov
  0 siblings, 0 replies; 8+ messages in thread
From: Anton Ivanov @ 2021-06-25  9:16 UTC (permalink / raw)
  To: Johannes Berg, linux-um; +Cc: Johannes Berg, kernel test robot



On 25/06/2021 09:34, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
> 
> A couple of sparse warnings happened here due to casts on
> the prints, a missing static and a missing include. Fix
> all of them.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Fixes: ca2e334232b6 ("lib: add iomem emulation (logic_iomem)")
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
> ---
>   lib/logic_iomem.c | 16 +++++++++-------
>   1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/lib/logic_iomem.c b/lib/logic_iomem.c
> index b76b92dd0f1f..9bdfde0c0f86 100644
> --- a/lib/logic_iomem.c
> +++ b/lib/logic_iomem.c
> @@ -6,6 +6,7 @@
>   #include <linux/types.h>
>   #include <linux/slab.h>
>   #include <linux/logic_iomem.h>
> +#include <asm/io.h>
>   
>   struct logic_iomem_region {
>   	const struct resource *res;
> @@ -78,7 +79,7 @@ static void __iomem *real_ioremap(phys_addr_t offset, size_t size)
>   static void real_iounmap(void __iomem *addr)
>   {
>   	WARN(1, "invalid iounmap for addr 0x%llx\n",
> -	     (unsigned long long)addr);
> +	     (unsigned long long __force)addr);
>   }
>   #endif /* CONFIG_LOGIC_IOMEM_FALLBACK */
>   
> @@ -172,14 +173,15 @@ EXPORT_SYMBOL(iounmap);
>   static u##sz real_raw_read ## op(const volatile void __iomem *addr)	\
>   {									\
>   	WARN(1, "Invalid read" #op " at address %llx\n",		\
> -	     (unsigned long long)addr);					\
> +	     (unsigned long long __force)addr);				\
>   	return (u ## sz)~0ULL;						\
>   }									\
>   									\
> -void real_raw_write ## op(u ## sz val, volatile void __iomem *addr)	\
> +static void real_raw_write ## op(u ## sz val,				\
> +				 volatile void __iomem *addr)		\
>   {									\
>   	WARN(1, "Invalid writeq" #op " of 0x%llx at address %llx\n",	\
> -	     (unsigned long long)val, (unsigned long long)addr);	\
> +	     (unsigned long long)val, (unsigned long long __force)addr);\
>   }									\
>   
>   MAKE_FALLBACK(b, 8);
> @@ -192,14 +194,14 @@ MAKE_FALLBACK(q, 64);
>   static void real_memset_io(volatile void __iomem *addr, int value, size_t size)
>   {
>   	WARN(1, "Invalid memset_io at address 0x%llx\n",
> -	     (unsigned long long)addr);
> +	     (unsigned long long __force)addr);
>   }
>   
>   static void real_memcpy_fromio(void *buffer, const volatile void __iomem *addr,
>   			       size_t size)
>   {
>   	WARN(1, "Invalid memcpy_fromio at address 0x%llx\n",
> -	     (unsigned long long)addr);
> +	     (unsigned long long __force)addr);
>   
>   	memset(buffer, 0xff, size);
>   }
> @@ -208,7 +210,7 @@ static void real_memcpy_toio(volatile void __iomem *addr, const void *buffer,
>   			     size_t size)
>   {
>   	WARN(1, "Invalid memcpy_toio at address 0x%llx\n",
> -	     (unsigned long long)addr);
> +	     (unsigned long long __force)addr);
>   }
>   #endif /* CONFIG_LOGIC_IOMEM_FALLBACK */
>   
> 

Acked-By: Anton Ivanov <anton.ivanov@cambridgegreys.com>

-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/

_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/4] um: make PCI emulation driver init/exit static
  2021-06-25  8:34 [PATCH 1/4] um: make PCI emulation driver init/exit static Johannes Berg
                   ` (2 preceding siblings ...)
  2021-06-25  8:34 ` [PATCH 4/4] um: virtio_uml: fix memory leak on init failures Johannes Berg
@ 2021-06-25  9:16 ` Anton Ivanov
  3 siblings, 0 replies; 8+ messages in thread
From: Anton Ivanov @ 2021-06-25  9:16 UTC (permalink / raw)
  To: Johannes Berg, linux-um; +Cc: Johannes Berg, kernel test robot



On 25/06/2021 09:34, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
> 
> The functions aren't used elsewhere, so they can be static.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Fixes: 68f5d3f3b654 ("um: add PCI over virtio emulation driver")
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
> ---
>   arch/um/drivers/virt-pci.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/um/drivers/virt-pci.c b/arch/um/drivers/virt-pci.c
> index 0b802834f40a..70c17de16662 100644
> --- a/arch/um/drivers/virt-pci.c
> +++ b/arch/um/drivers/virt-pci.c
> @@ -810,7 +810,7 @@ void *pci_root_bus_fwnode(struct pci_bus *bus)
>   	return um_pci_fwnode;
>   }
>   
> -int um_pci_init(void)
> +static int um_pci_init(void)
>   {
>   	int err, i;
>   
> @@ -884,7 +884,7 @@ int um_pci_init(void)
>   }
>   module_init(um_pci_init);
>   
> -void um_pci_exit(void)
> +static void um_pci_exit(void)
>   {
>   	unregister_virtio_driver(&um_pci_virtio_driver);
>   	irq_domain_remove(um_pci_msi_domain);
> 

Acked-By: Anton Ivanov <anton.ivanov@cambridgegreys.com>

-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/

_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-06-25  9:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-25  8:34 [PATCH 1/4] um: make PCI emulation driver init/exit static Johannes Berg
2021-06-25  8:34 ` [PATCH 2/4] lib/logic_iomem: fix sparse warnings Johannes Berg
2021-06-25  9:16   ` Anton Ivanov
2021-06-25  8:34 ` [PATCH 3/4] um: virtio_uml: include linux/virtio-uml.h Johannes Berg
2021-06-25  9:16   ` Anton Ivanov
2021-06-25  8:34 ` [PATCH 4/4] um: virtio_uml: fix memory leak on init failures Johannes Berg
2021-06-25  9:15   ` Anton Ivanov
2021-06-25  9:16 ` [PATCH 1/4] um: make PCI emulation driver init/exit static Anton Ivanov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.