[PATCH 13/19] driver: have dev_request_mem_region_err_null warn if resource starts at 0

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



dev_request_mem_region_err_null() is used very scarcely, because it
doesn't allow differentiating between NULL and a MMIO region at address 0.

Using it in the latter case is always a bug, so add a WARN_ON that warns
about this. This should make it safe to use at more places, which will
come in handy to implement Linux API that uses NULL as error value.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 drivers/base/driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 4f18f5bb8123..6548aec9b27b 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -541,7 +541,7 @@ void __iomem *dev_request_mem_region_err_null(struct device *dev, int num)
 	struct resource *res;
 
 	res = dev_request_mem_resource(dev, num);
-	if (IS_ERR(res))
+	if (IS_ERR(res) || WARN_ON(!res->start))
 		return NULL;
 
 	return IOMEM(res->start);
-- 
2.39.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux