summaryrefslogtreecommitdiffstats
path: root/net/core/gen_stats.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-07-30 10:08:09 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-07-30 10:08:09 +0200
commitd2fc88a61b4ea99f574bde16e92718e22f312136 (patch)
treef256841ebcbc3b90fc29d7fa751610ba9aac5a2b /net/core/gen_stats.c
parente16f4f3e0b7daecd48d4f944ab4147c1a6cb16a8 (diff)
parentacb1872577b346bd15ab3a3f8dff780d6cca4b70 (diff)
downloadlinux-d2fc88a61b4ea99f574bde16e92718e22f312136.tar.bz2
Merge 4.18-rc7 into driver-core-next
We need the driver core changes in here as well for testing. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net/core/gen_stats.c')
-rw-r--r--net/core/gen_stats.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/net/core/gen_stats.c b/net/core/gen_stats.c
index b2b2323bdc84..188d693cb251 100644
--- a/net/core/gen_stats.c
+++ b/net/core/gen_stats.c
@@ -77,8 +77,20 @@ gnet_stats_start_copy_compat(struct sk_buff *skb, int type, int tc_stats_type,
d->lock = lock;
spin_lock_bh(lock);
}
- if (d->tail)
- return gnet_stats_copy(d, type, NULL, 0, padattr);
+ if (d->tail) {
+ int ret = gnet_stats_copy(d, type, NULL, 0, padattr);
+
+ /* The initial attribute added in gnet_stats_copy() may be
+ * preceded by a padding attribute, in which case d->tail will
+ * end up pointing at the padding instead of the real attribute.
+ * Fix this so gnet_stats_finish_copy() adjusts the length of
+ * the right attribute.
+ */
+ if (ret == 0 && d->tail->nla_type == padattr)
+ d->tail = (struct nlattr *)((char *)d->tail +
+ NLA_ALIGN(d->tail->nla_len));
+ return ret;
+ }
return 0;
}