linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/5] memremap: Check for size parameter
@ 2019-11-15 18:00 Andy Shevchenko
  2019-11-15 18:00 ` [PATCH v1 2/5] dma-mapping: Drop duplicate check for size parameter of memremap() Andy Shevchenko
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Andy Shevchenko @ 2019-11-15 18:00 UTC (permalink / raw)
  To: linux-kernel, Christoph Hellwig
  Cc: Andy Shevchenko, Dan Williams, Arnd Bergmann, Marek Szyprowski,
	Robin Murphy, Jaroslav Kysela, Takashi Iwai,
	Pierre-Louis Bossart, Ard Biesheuvel, Alex Williamson,
	Cornelia Huck

There is no use of memremap() to be called with size = 0.
Simple return NULL pointer and allow callers to drop this check.

Fixes: 92281dee825f ("arch: introduce memremap()")
Cc: Christoph Hellwig <hch@lst.de>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Alex Williamson <alex.williamson@redhat.com>
Cc: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 kernel/iomem.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/iomem.c b/kernel/iomem.c
index 62c92e43aa0d..bf7a5fc32760 100644
--- a/kernel/iomem.c
+++ b/kernel/iomem.c
@@ -74,6 +74,9 @@ void *memremap(resource_size_t offset, size_t size, unsigned long flags)
 				       IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE);
 	void *addr = NULL;
 
+	if (!size)
+		return NULL;
+
 	if (!flags)
 		return NULL;
 
-- 
2.24.0


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

end of thread, other threads:[~2020-04-15 14:59 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-15 18:00 [PATCH v1 1/5] memremap: Check for size parameter Andy Shevchenko
2019-11-15 18:00 ` [PATCH v1 2/5] dma-mapping: Drop duplicate check for size parameter of memremap() Andy Shevchenko
2019-11-16 16:29   ` Christoph Hellwig
2019-11-15 18:00 ` [PATCH v1 3/5] ALSA: hda: " Andy Shevchenko
2019-11-15 18:00 ` [PATCH v1 4/5] efi/esrt: " Andy Shevchenko
2019-11-15 18:00 ` [PATCH v1 5/5] vfio/pci: " Andy Shevchenko
2019-11-15 22:52   ` Alex Williamson
2019-11-16 16:29 ` [PATCH v1 1/5] memremap: Check for size parameter Christoph Hellwig
2020-04-15 14:58   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).