diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 2a0c5f3b0e50..286196e3a35d 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -967,7 +967,8 @@ static inline void nvmem_shift_read_buffer_in_place(struct nvmem_cell *cell, *p-- = 0; /* clear msb bits if any leftover in the last byte */ - *p &= GENMASK((cell->nbits%BITS_PER_BYTE) - 1, 0); + if (cell->nbits % BITS_PER_BYTE) + *p &= GENMASK((cell->nbits % BITS_PER_BYTE) - 1, 0); } static int __nvmem_cell_read(struct nvmem_device *nvmem,