Re: [PATCH] staging: rtl8723bs: remove copy function
From: Andy Shevchenko
Date: Fri Mar 20 2026 - 04:27:27 EST
On Fri, Mar 20, 2026 at 10:18:31AM +0300, Bera Yüzlü wrote:
> GetU1ByteIntegerFromStringInDecimal() is a copy of kstrtou8().
> Remove its usages to kstrtou8() and check the return value.
...
> void PHY_SetTxPowerLimit( ... )
> {
> struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
> - u8 regulation = 0, bandwidth = 0, rateSection = 0, channel;
> - s8 powerLimit = 0, prevPowerLimit, channelIndex;
> + u8 regulation = 0, bandwidth = 0, rateSection = 0, channel, powerLimit;
> + s8 prevPowerLimit, channelIndex;
> + int ret;
>
> - GetU1ByteIntegerFromStringInDecimal((s8 *)Channel, &channel);
> - GetU1ByteIntegerFromStringInDecimal((s8 *)PowerLimit, &powerLimit);
> + ret = kstrtou8((const char *)Channel, 10, &channel);
> + if (ret)
> + return;
> +
> + ret = kstrtou8((const char *)PowerLimit, 10, &powerLimit);
> + if (ret)
> + return;
This will change behaviour on the invalid data. Before it was just partially
converted here and continue, now it breaks an execution. The commit message
does not explain if it's safe to do or not (i.o.w. if there is a guarantee
that in current state the input will be always in the correct form).
Otherwise, you probably want to use one of simple_strtou*().
> powerLimit = powerLimit > MAX_POWER_INDEX ? MAX_POWER_INDEX : powerLimit;
--
With Best Regards,
Andy Shevchenko