Re: [net-next PATCH v2 4/8] net: dsa: realtek: rtl8365mb: add table lookup interface
From: Jakub Kicinski
Date: Tue May 05 2026 - 21:26:44 EST
On Sun, 03 May 2026 03:18:24 -0300 Luiz Angelo Daros de Luca wrote:
> +int rtl8365mb_table_query(struct realtek_priv *priv,
> + enum rtl8365mb_table table,
> + enum rtl8365mb_table_op op, u16 *addr,
> + enum rtl8365mb_table_l2_method method,
> + u16 port, u16 *data, size_t size)
> +{
> + bool addr_as_input = true;
> + bool write_data = false;
> + int ret = 0;
> + u32 cmd;
> + u32 val;
> + u32 hit;
> +
> + if (!addr) {
> + dev_err(priv->dev, "%s: addr is NULL\n", __func__);
> + return -EINVAL;
> + }
> +
> + if (!data) {
> + dev_err(priv->dev, "%s: data is NULL\n", __func__);
> + return -EINVAL;
> + }
> +
> + if (size > RTL8365MB_TABLE_ENTRY_MAX_SIZE) {
> + dev_err(priv->dev, "%s: size too big: %zu\n", __func__, size);
> + return -E2BIG;
> + }
> +
> + if (size == 0) {
> + dev_err(priv->dev, "%s: size is 0\n", __func__);
> + return -EINVAL;
> + }
Defensive checks are discouraged in the kernel. AI will make short work
of finding such trivial violations.