Message ID | 1548058881-147159-1-git-send-email-weiyongjun1@huawei.com |
---|---|
State | Superseded |
Delegated to: | David Miller |
Headers | show |
Series | [net-next] devlink: Fix error return code in devlink_health_buffer_prepare_skb() | expand |
On 1/21/2019 10:21 AM, Wei Yongjun wrote: > Fix to return a negative error code -EMSGSIZE from the error handling > case, otherwise 0 or uninitialized value may be returned. > > Fixes: cb5ccfbe73b3 ("devlink: Add health buffer support") > Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com> Thanks for the fix! However, I am working to replace this entire code section, will squash your patch to the new code. > --- > net/core/devlink.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/net/core/devlink.c b/net/core/devlink.c > index 60248a5..0d4c774 100644 > --- a/net/core/devlink.c > +++ b/net/core/devlink.c > @@ -4008,8 +4008,10 @@ void devlink_health_buffer_nest_cancel(struct devlink_health_buffer *buffer) > case DEVLINK_ATTR_HEALTH_BUFFER_OBJECT_VALUE: > case DEVLINK_ATTR_HEALTH_BUFFER_OBJECT_VALUE_ARRAY: > buffer_nlattr[i] = nla_nest_start(skb, desc->attrtype); > - if (!buffer_nlattr[i]) > + if (!buffer_nlattr[i]) { > + err = -EMSGSIZE; > goto nla_put_failure; > + } > i++; > break; > case DEVLINK_ATTR_HEALTH_BUFFER_OBJECT_VALUE_DATA: > > >
diff --git a/net/core/devlink.c b/net/core/devlink.c index 60248a5..0d4c774 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -4008,8 +4008,10 @@ void devlink_health_buffer_nest_cancel(struct devlink_health_buffer *buffer) case DEVLINK_ATTR_HEALTH_BUFFER_OBJECT_VALUE: case DEVLINK_ATTR_HEALTH_BUFFER_OBJECT_VALUE_ARRAY: buffer_nlattr[i] = nla_nest_start(skb, desc->attrtype); - if (!buffer_nlattr[i]) + if (!buffer_nlattr[i]) { + err = -EMSGSIZE; goto nla_put_failure; + } i++; break; case DEVLINK_ATTR_HEALTH_BUFFER_OBJECT_VALUE_DATA:
Fix to return a negative error code -EMSGSIZE from the error handling case, otherwise 0 or uninitialized value may be returned. Fixes: cb5ccfbe73b3 ("devlink: Add health buffer support") Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com> --- net/core/devlink.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)