zram: rework copy of compressor name in comp_algorithm_store()
Subsystems (2)
PATCH 20/21 zram: rework copy of compressor name in comp_algorithm_store()
From: Matthias Kaehlcke <[email protected]>
Subject: zram: rework copy of compressor name in comp_algorithm_store()
comp_algorithm_store() passes the size of the source buffer to strlcpy() instead of the destination buffer size. Make it explicit that the two buffers have the same size and use strcpy() instead of strlcpy(). The latter can be done safely since the function ensures that the string in the source buffer is terminated.
Signed-off-by Matthias Kaehlcke <[email protected]>
Reviewed-by Douglas Anderson <[email protected]>
Reviewed-by Sergey Senozhatsky <[email protected]>
Acked-by Minchan Kim <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
drivers/block/zram/zram_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/zram/zram_drv.c renamed from drivers/block/zram/zram_drv.c~zram-rework-copy-of-compressor-name-in-comp_algorithm_store +2 -2
@@ -308,7 +308,7 @@ static ssize_t comp_algorithm_store(stru struct device_attribute *attr, const char *buf, size_t len) { struct zram *zram = dev_to_zram(dev); -char compressor[CRYPTO_MAX_ALG_NAME ]; +char compressor[ARRAY_SIZE (zram->compressor)];size_t sz;strlcpy (compressor, buf,sizeof (compressor));
@@ -327,7 +327,7 @@ static ssize_t comp_algorithm_store(strureturn -EBUSY ; } -strlcpy (zram->compressor, compressor,sizeof (compressor)); +strcpy (zram->compressor, compressor);up_write (&zram->init_lock);return len; }
_