[RPCD PATCH v4 4/4] iwinfo: export center channel for info ubus call

Jo-Philipp Wich jo at mein.io
Tue Jan 5 17:45:01 EST 2021


Hi,

comment below.

> [...]
> diff --git a/iwinfo.c b/iwinfo.c
> index 45ca784..94fa822 100644
> --- a/iwinfo.c
> +++ b/iwinfo.c
> @@ -364,6 +364,8 @@ rpc_iwinfo_info(struct ubus_context *ctx, struct ubus_object *obj,
>  
>  	rpc_iwinfo_call_int("mode", iw->mode, IWINFO_OPMODE_NAMES);
>  	rpc_iwinfo_call_int("channel", iw->channel, NULL);

You need to check `iw->center_chan1` and `iw->center_chan2` for non-null
before calling them, otherwise rpcd will crash when querying wifi interfaces
not using the nl80211 backend.

Wrapping the next two lines into `if (iw->center_chan1) { ... }` should do.
Even better would be adding stubs returning `-1` to the other iwinfo backends
(madwifi, wl, wext).

> +	rpc_iwinfo_call_int("center_chan1", iw->center_chan1, NULL);
> +	rpc_iwinfo_call_int("center_chan2", iw->center_chan2, NULL);
>  
>  	rpc_iwinfo_call_int("frequency", iw->frequency, NULL);
>  	rpc_iwinfo_call_int("frequency_offset", iw->frequency_offset, NULL);
> 

~ Jo

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.openwrt.org/pipermail/openwrt-devel/attachments/20210105/45192830/attachment.sig>


More information about the openwrt-devel mailing list