]> git.baikalelectronics.ru Git - kernel.git/commit
sysfs: correctly handle short reads on PREALLOC attrs.
authorNeilBrown <neilb@suse.com>
Wed, 5 Aug 2015 22:27:55 +0000 (08:27 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 4 Oct 2015 18:42:22 +0000 (19:42 +0100)
commitc5f3509c7433348fdd46e9e0c2c3f31fb88f8321
tree886ed45dc33cdfd927a395fceccbe2bd3d5cc4b5
parent7906bab6c032db84f08cc119d03cb5c56d989609
sysfs: correctly handle short reads on PREALLOC attrs.

attributes declared with __ATTR_PREALLOC use sysfs_kf_read()
which ignores the 'count' arg.
So a 1-byte read request can return more bytes than that.

This is seen with the 'dash' shell when 'read' is used on
some 'md' sysfs attributes.

So only return the 'min' of count and the attribute length.

Signed-off-by: NeilBrown <neilb@suse.com>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/sysfs/file.c