Search Linux Wireless

Re: [PATCH] rtw88: add debugfs to fix tx rate

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I know there's other discussion on this patch, related to nl80211 vs.
debugfs, but in case the discussion ends up permitting debugfs, I'll
put my review notes in.

Reviewed-by: Brian Norris <briannorris@xxxxxxxxxxxx>
Tested-by: Brian Norris <briannorris@xxxxxxxxxxxx>

On Thu, Mar 12, 2020 at 11:51 PM <yhchuang@xxxxxxxxxxx> wrote:
> +static ssize_t rtw_debugfs_set_fix_rate(struct file *filp,
> +                                       const char __user *buffer,
> +                                       size_t count, loff_t *loff)
> +{
> +       struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
> +       struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
> +       struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
> +       struct rtw_dm_info *dm_info = &rtwdev->dm_info;
> +       u8 fix_rate;
> +       char tmp[32 + 1];
> +       int ret;
> +
> +       rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 1);
> +
> +       ret = kstrtou8(tmp, 0, &fix_rate);
> +       if (ret) {
> +               rtw_warn(rtwdev, "invalid args, [rate]\n");

Seems like you don't actually need this print, as it doesn't provide
any additional data that you don't get through the return code. People
interacting with this debugfs interface will already see things like
"write error: Invalid argument" if they're handling write() errors
appropriately.

> +               return ret;
> +       }
> +
> +       dm_info->fix_rate = fix_rate;

It feels like you should do some real bounds checking here; as-is,
you're allowing anything in [DESC_RATE_MAX..0xff] to mean "disabled",
whereas it seems much more reasonable to specify a single value that
means "disabled". So you could do:

  if (fix_rate >= DESC_RATE_MAX && fix_rate != U8_MAX)
    return -EINVAL;

Brian

> +
> +       return count;
> +}
> +



[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux