Skip to content

Commit da95969

Browse files
Marek Vasutgregkh
authored andcommitted
nvmem: core: Check read_only flag for force_ro in bin_attr_nvmem_write()
The bin_attr_nvmem_write() must check the read_only flag and block writes on read-only devices, now that a nvmem device can be switched between read-write and read-only mode at runtime using the force_ro attribute. Add the missing check. Fixes: 9d7eb23 ("nvmem: core: Implement force_ro sysfs attribute") Cc: [email protected] Signed-off-by: Marek Vasut <[email protected]> Signed-off-by: Srinivas Kandagatla <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent ce8f9fb commit da95969

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/nvmem/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj,
267267

268268
count = round_down(count, nvmem->word_size);
269269

270-
if (!nvmem->reg_write)
270+
if (!nvmem->reg_write || nvmem->read_only)
271271
return -EPERM;
272272

273273
rc = nvmem_reg_write(nvmem, pos, buf, count);

0 commit comments

Comments
 (0)