mac80211: fix incorrect strlen of .write in debugfs
authorShayne Chen <shayne.chen@mediatek.com>
Tue, 12 Jan 2021 03:20:28 +0000 (11:20 +0800)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 14 Jan 2021 21:23:56 +0000 (22:23 +0100)
commit6020d534fa012b80c6d13811dc4d2dfedca2e403
tree4421f1c2cb4d5d6ec860fa29ef4d8e75a75c8b06
parentc2083e280a3d4f71941c9c57992d4e621e4e33c5
mac80211: fix incorrect strlen of .write in debugfs

This fixes strlen mismatch problems happening in some .write callbacks
of debugfs.

When trying to configure airtime_flags in debugfs, an error appeared:
ash: write error: Invalid argument

The error is returned from kstrtou16() since a wrong length makes it
miss the real end of input string.  To fix this, use count as the string
length, and set proper end of string for a char buffer.

The debug print is shown - airtime_flags_write: count = 2, len = 8,
where the actual length is 2, but "len = strlen(buf)" gets 8.

Also cleanup the other similar cases for the sake of consistency.

Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Link: https://lore.kernel.org/r/20210112032028.7482-1-shayne.chen@mediatek.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/debugfs.c