From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jakub Kicinski Subject: Re: [net-next 01/10] devlink: Fix param set handling for string type Date: Wed, 1 Aug 2018 15:33:37 -0700 Message-ID: <20180801153337.5b886cd8@cakuba.netronome.com> References: <20180801215255.6642-1-saeedm@mellanox.com> <20180801215255.6642-2-saeedm@mellanox.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: "David S. Miller" , netdev@vger.kernel.org, Alexander Duyck , Bjorn Helgaas , Moshe Shemesh To: Saeed Mahameed , Jiri Pirko Return-path: Received: from mail-qk0-f177.google.com ([209.85.220.177]:35980 "EHLO mail-qk0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727315AbeHBAVm (ORCPT ); Wed, 1 Aug 2018 20:21:42 -0400 Received: by mail-qk0-f177.google.com with SMTP id x192-v6so225390qkb.3 for ; Wed, 01 Aug 2018 15:33:41 -0700 (PDT) In-Reply-To: <20180801215255.6642-2-saeedm@mellanox.com> Sender: netdev-owner@vger.kernel.org List-ID: On Wed, 1 Aug 2018 14:52:46 -0700, Saeed Mahameed wrote: > From: Moshe Shemesh > > In case devlink param type is string, it needs to copy the string value > it got from the input to devlink_param_value. > > Fixes: e3b7ca18ad7b ("devlink: Add param set command") > Signed-off-by: Moshe Shemesh > Acked-by: Jiri Pirko > Signed-off-by: Saeed Mahameed > --- > include/net/devlink.h | 2 +- > net/core/devlink.c | 3 ++- > 2 files changed, 3 insertions(+), 2 deletions(-) > > diff --git a/include/net/devlink.h b/include/net/devlink.h > index b9b89d6604d4..b0e17c025fdc 100644 > --- a/include/net/devlink.h > +++ b/include/net/devlink.h > @@ -311,7 +311,7 @@ union devlink_param_value { > u8 vu8; > u16 vu16; > u32 vu32; > - const char *vstr; > + char vstr[DEVLINK_PARAM_MAX_STRING_VALUE]; > bool vbool; > }; > > diff --git a/net/core/devlink.c b/net/core/devlink.c > index 65fc366a78a4..61e126c28526 100644 > --- a/net/core/devlink.c > +++ b/net/core/devlink.c > @@ -3014,7 +3014,8 @@ devlink_param_value_get_from_info(const struct devlink_param *param, > if (nla_len(info->attrs[DEVLINK_ATTR_PARAM_VALUE_DATA]) > > DEVLINK_PARAM_MAX_STRING_VALUE) > return -EINVAL; > - value->vstr = nla_data(info->attrs[DEVLINK_ATTR_PARAM_VALUE_DATA]); > + strcpy(value->vstr, > + nla_data(info->attrs[DEVLINK_ATTR_PARAM_VALUE_DATA])); DEVLINK_ATTR_PARAM_VALUE_DATA is a type mux, I'm struggling to find in the code where it's checked for being null-terminated for strings. > break; > case DEVLINK_PARAM_TYPE_BOOL: > value->vbool = info->attrs[DEVLINK_ATTR_PARAM_VALUE_DATA] ?