Skip to contentSkip to conversation

nvmem: Use the same permissions for eeprom as for nvmem

BACKPORT Jean Delvare 2 participants 2 messages Sep 17, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

[ Upstream commit e70d8b287301eb6d7c7761c6171c56af62110ea3 ]

The compatibility "eeprom" attribute is currently root-only no matter what the configuration says. The "nvmem" attribute does respect the setting of the root_only configuration bit, so do the same for "eeprom".

Fixes b6c217ab9be6 ("nvmem: Add backwards compatibility support for older EEPROM drivers.")
Cc Andrew Lunn <[email protected]>
Cc Srinivas Kandagatla <[email protected]>
Cc Arnd Bergmann <[email protected]>

---
This is the backport of commit e70d8b287301 "nvmem: Use the same permissions for eeprom as for nvmem" for stable kernel branches 4.19, 4.14 and 4.9. Thanks.

 drivers/nvmem/core.c |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/nvmem/core.c +11 -4
@@ -415,10 +415,17 @@ static int nvmem_setup_compat(struct nvm
 	if (!config->base_dev)
 		return -EINVAL;
 
-	if (nvmem->read_only)
-		nvmem->eeprom = bin_attr_ro_root_nvmem;
-	else
-		nvmem->eeprom = bin_attr_rw_root_nvmem;
+	if (nvmem->read_only) {
+		if (config->root_only)
+			nvmem->eeprom = bin_attr_ro_root_nvmem;
+		else
+			nvmem->eeprom = bin_attr_ro_nvmem;
+	} else {
+		if (config->root_only)
+			nvmem->eeprom = bin_attr_rw_root_nvmem;
+		else
+			nvmem->eeprom = bin_attr_rw_nvmem;
+	}
 	nvmem->eeprom.attr.name = "eeprom";
 	nvmem->eeprom.size = nvmem->size;
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
Signature · 2 lines
Jean Delvare
SUSE L3 Support
#1 lore raw
Quoted 16 lines · Jean Delvare

[ Upstream commit e70d8b287301eb6d7c7761c6171c56af62110ea3 ]

The compatibility "eeprom" attribute is currently root-only no matter what the configuration says. The "nvmem" attribute does respect the setting of the root_only configuration bit, so do the same for "eeprom".

Fixes b6c217ab9be6 ("nvmem: Add backwards compatibility support for older EEPROM drivers.")
Cc Andrew Lunn <[email protected]>
Cc Srinivas Kandagatla <[email protected]>
Cc Arnd Bergmann <[email protected]>
Quoted 4 lines

---
This is the backport of commit e70d8b287301 "nvmem: Use the same permissions for eeprom as for nvmem" for stable kernel branches 4.19, 4.14 and 4.9. Thanks.

Now queued up, thanks.

greg k-h