提交 682f560b 编写于 作者: D Dan Carpenter 提交者: Paolo Abeni

net: microchip: sparx5: Fix error handling in vcap_show_admin()

If vcap_dup_rule() fails that leads to an error pointer dereference
side the call to vcap_free_rule().  Also it only returns an error if the
very last call to vcap_read_rule() fails and it returns success for
other errors.

I've changed it to just stop printing after the first error and return
an error code.

Fixes: 3a792156 ("net: microchip: sparx5: Add VCAP rule debugFS support for the VCAP API")
Signed-off-by: NDan Carpenter <error27@gmail.com>
Reviewed-by: NSteen Hegelund <Steen.Hegelund@microchip.com>
Link: https://lore.kernel.org/r/Y4XUUx9kzurBN+BV@kiliSigned-off-by: NPaolo Abeni <pabeni@redhat.com>
上级 e5214f36
......@@ -639,17 +639,24 @@ static int vcap_show_admin(struct vcap_control *vctrl,
mutex_lock(&admin->lock);
list_for_each_entry(elem, &admin->rules, list) {
ri = vcap_dup_rule(elem);
if (IS_ERR(ri))
goto free_rule;
if (IS_ERR(ri)) {
ret = PTR_ERR(ri);
goto err_unlock;
}
/* Read data from VCAP */
ret = vcap_read_rule(ri);
if (ret)
goto free_rule;
goto err_free_rule;
out->prf(out->dst, "\n");
vcap_show_admin_rule(vctrl, admin, out, ri);
free_rule:
vcap_free_rule((struct vcap_rule *)ri);
}
mutex_unlock(&admin->lock);
return 0;
err_free_rule:
vcap_free_rule((struct vcap_rule *)ri);
err_unlock:
mutex_unlock(&admin->lock);
return ret;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册