From: Pascal Ernster Date: Thu, 5 Jan 2023 05:56:38 +0000 (+0100) Subject: realtek: 5.15: Improve error handling in rtl838x_pie_rule_write() X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=720b2431716b16a93848e10788ae6d36856a34b2;p=openwrt%2Fstaging%2Fwigyori.git realtek: 5.15: Improve error handling in rtl838x_pie_rule_write() In target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.c, make rtl838x_pie_rule_write() return non-zero value case of error. Signed-off-by: Pascal Ernster --- diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.c index 8a162df9a4..504b29822a 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.c +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.c @@ -1335,7 +1335,7 @@ static int rtl838x_pie_rule_write(struct rtl838x_switch_priv *priv, int idx, str /* Access IACL table (1) via register 0 */ struct table_reg *q = rtl_table_get(RTL8380_TBL_0, 1); u32 r[18]; - int err = 0; + int err; int block = idx / PIE_BLOCK_SIZE; u32 t_select = sw_r32(RTL838X_ACL_BLK_TMPLTE_CTRL(block)); @@ -1344,17 +1344,21 @@ static int rtl838x_pie_rule_write(struct rtl838x_switch_priv *priv, int idx, str for (int i = 0; i < 18; i++) r[i] = 0; - if (!pr->valid) - goto err_out; + if (!pr->valid) { + err = -EINVAL; + pr_err("Rule invalid\n"); + goto errout; + } rtl838x_write_pie_fixed_fields(r, pr); pr_debug("%s: template %d\n", __func__, (t_select >> (pr->tid * 3)) & 0x7); rtl838x_write_pie_templated(r, pr, fixed_templates[(t_select >> (pr->tid * 3)) & 0x7]); - if (rtl838x_write_pie_action(r, pr)) { + err = rtl838x_write_pie_action(r, pr); + if (err) { pr_err("Rule actions too complex\n"); - goto err_out; + goto errout; } /* rtl838x_pie_rule_dump_raw(r); */ @@ -1362,7 +1366,7 @@ static int rtl838x_pie_rule_write(struct rtl838x_switch_priv *priv, int idx, str for (int i = 0; i < 18; i++) sw_w32(r[i], rtl_table_data(q, i)); -err_out: +errout: rtl_table_write(q, idx); rtl_table_release(q);