Message ID | 1392127598-3719-1-git-send-email-fx.lebail@yahoo.com |
---|---|
State | Rejected, archived |
Delegated to: | David Miller |
Headers | show |
On Tue, 2014-02-11 at 15:06 +0100, Francois-Xavier Le Bail wrote: > Find by cppcheck: > [net/core/rtnetlink.c:1842]: (warning) Using size of pointer linkinfo instead of size of its data. > > Signed-off-by: Francois-Xavier Le Bail <fx.lebail@yahoo.com> > --- > > The diagnosis of cppcheck seems relevant. > > net/core/rtnetlink.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c > index 048dc8d..9a5dbf1 100644 > --- a/net/core/rtnetlink.c > +++ b/net/core/rtnetlink.c > @@ -1839,7 +1839,7 @@ replay: > if (err < 0) > return err; > } else > - memset(linkinfo, 0, sizeof(linkinfo)); > + memset(linkinfo, 0, sizeof(*linkinfo)); > > if (linkinfo[IFLA_INFO_KIND]) { > nla_strlcpy(kind, linkinfo[IFLA_INFO_KIND], sizeof(kind)); This is absolutely wrong. struct nlattr *linkinfo[IFLA_INFO_MAX+1]; sizeof(linkinfo) is totally appropriate sizeof(*linkinfo) is equal to sizeof(void *), and this is not what we need here. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
> From: Eric Dumazet <eric.dumazet@gmail.com> > To: Francois-Xavier Le Bail <fx.lebail@yahoo.com> >> Find by cppcheck: >> [net/core/rtnetlink.c:1842]: (warning) Using size of pointer linkinfo > instead of size of its data. >> >> Signed-off-by: Francois-Xavier Le Bail <fx.lebail@yahoo.com> >> --- >> >> The diagnosis of cppcheck seems relevant. >> >> net/core/rtnetlink.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> > This is absolutely wrong. > > struct nlattr *linkinfo[IFLA_INFO_MAX+1]; > > sizeof(linkinfo) is totally appropriate > > sizeof(*linkinfo) is equal to sizeof(void *), and this is not what we > need here. Oops, sorry for the noise. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 048dc8d..9a5dbf1 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -1839,7 +1839,7 @@ replay: if (err < 0) return err; } else - memset(linkinfo, 0, sizeof(linkinfo)); + memset(linkinfo, 0, sizeof(*linkinfo)); if (linkinfo[IFLA_INFO_KIND]) { nla_strlcpy(kind, linkinfo[IFLA_INFO_KIND], sizeof(kind));
Find by cppcheck: [net/core/rtnetlink.c:1842]: (warning) Using size of pointer linkinfo instead of size of its data. Signed-off-by: Francois-Xavier Le Bail <fx.lebail@yahoo.com> --- The diagnosis of cppcheck seems relevant. net/core/rtnetlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html