lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Sat, 25 Nov 2017 23:59:07 +0100
From:   Heiner Kallweit <hkallweit1@...il.com>
To:     Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
Cc:     Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: [PATCH] nvmem: core: let stride and word_size default to 1

If the caller doesn't set stride and/or word_size in struct nvmem_config 
then nvmem_register accepts this but we may face strange effects later
due to both values being 0. Therefore use 1 as default for both values.

Signed-off-by: Heiner Kallweit <hkallweit1@...il.com>
---
 drivers/nvmem/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index ba0e3b453..129dad0ce 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -463,8 +463,8 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
 	nvmem->owner = config->owner;
 	if (!nvmem->owner && config->dev->driver)
 		nvmem->owner = config->dev->driver->owner;
-	nvmem->stride = config->stride;
-	nvmem->word_size = config->word_size;
+	nvmem->stride = config->stride ?: 1;
+	nvmem->word_size = config->word_size ?: 1;
 	nvmem->size = config->size;
 	nvmem->dev.type = &nvmem_provider_type;
 	nvmem->dev.bus = &nvmem_bus_type;
-- 
2.15.0

Powered by blists - more mailing lists