* [PATCH] staging: r8188eu: handle rtw_init_netdev_name() failure appropriately
@ 2022-01-16 19:26 Vihas Mak
2022-01-16 21:47 ` Pavel Skripkin
2022-01-18 15:07 ` Dan Carpenter
0 siblings, 2 replies; 5+ messages in thread
From: Vihas Mak @ 2022-01-16 19:26 UTC (permalink / raw)
To: Larry.Finger, phil, gregkh, martin, straube.linux
Cc: linux-staging, linux-kernel, Vihas Mak
rtw_init_netdev_name() calls dev_alloc_name() which allocates the name
for the device as per the given name format.
It returns a negative err code if the format is invalid. Currently the
name format is specified by the module parameter "ifname".
Warn the user if "ifname" is invalid.
Signed-off-by: Vihas Mak <makvihas@gmail.com>
---
drivers/staging/r8188eu/os_dep/usb_intf.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c
index 91792dfd3..875815b5e 100644
--- a/drivers/staging/r8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/r8188eu/os_dep/usb_intf.c
@@ -399,7 +399,10 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
DBG_88E("can't get autopm:\n");
/* alloc dev name after read efuse. */
- rtw_init_netdev_name(pnetdev, padapter->registrypriv.ifname);
+ if (rtw_init_netdev_name(pnetdev, padapter->registrypriv.ifname) < 0) {
+ DBG_88E("rtw_init_netdev_name failed, ifname:%s\n",
+ padapter->registrypriv.ifname);
+ }
rtw_macaddr_cfg(padapter->eeprompriv.mac_addr);
rtw_init_wifidirect_addrs(padapter, padapter->eeprompriv.mac_addr,
padapter->eeprompriv.mac_addr);
--
2.30.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: r8188eu: handle rtw_init_netdev_name() failure appropriately
2022-01-16 19:26 [PATCH] staging: r8188eu: handle rtw_init_netdev_name() failure appropriately Vihas Mak
@ 2022-01-16 21:47 ` Pavel Skripkin
2022-01-17 4:05 ` Vihas Mak
2022-01-18 15:07 ` Dan Carpenter
1 sibling, 1 reply; 5+ messages in thread
From: Pavel Skripkin @ 2022-01-16 21:47 UTC (permalink / raw)
To: Vihas Mak, Larry.Finger, phil, gregkh, martin, straube.linux
Cc: linux-staging, linux-kernel
Hi Vihas,
On 1/16/22 22:26, Vihas Mak wrote:
> rtw_init_netdev_name() calls dev_alloc_name() which allocates the name
> for the device as per the given name format.
> It returns a negative err code if the format is invalid. Currently the
> name format is specified by the module parameter "ifname".
> Warn the user if "ifname" is invalid.
>
> Signed-off-by: Vihas Mak <makvihas@gmail.com>
> ---
> drivers/staging/r8188eu/os_dep/usb_intf.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c
> index 91792dfd3..875815b5e 100644
> --- a/drivers/staging/r8188eu/os_dep/usb_intf.c
> +++ b/drivers/staging/r8188eu/os_dep/usb_intf.c
> @@ -399,7 +399,10 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
> DBG_88E("can't get autopm:\n");
>
> /* alloc dev name after read efuse. */
> - rtw_init_netdev_name(pnetdev, padapter->registrypriv.ifname);
> + if (rtw_init_netdev_name(pnetdev, padapter->registrypriv.ifname) < 0) {
> + DBG_88E("rtw_init_netdev_name failed, ifname:%s\n",
> + padapter->registrypriv.ifname);
> + }
> rtw_macaddr_cfg(padapter->eeprompriv.mac_addr);
> rtw_init_wifidirect_addrs(padapter, padapter->eeprompriv.mac_addr,
> padapter->eeprompriv.mac_addr);
rtw_init_netdev_name() has an error message in case of allocation
failure. It looks like it's better to handle the error normally and pass
it to caller
With regards,
Pavel Skripkin
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: r8188eu: handle rtw_init_netdev_name() failure appropriately
2022-01-16 21:47 ` Pavel Skripkin
@ 2022-01-17 4:05 ` Vihas Mak
0 siblings, 0 replies; 5+ messages in thread
From: Vihas Mak @ 2022-01-17 4:05 UTC (permalink / raw)
To: Pavel Skripkin
Cc: Larry.Finger, Phillip Potter, Greg KH, martin, straube.linux,
linux-staging, linux-kernel
>> rtw_init_netdev_name() has an error message in case of allocation
>> failure. It looks like it's better to handle the error normally and pass
>> it to caller
By that you mean:
goto handle_dualmac;
and freeing the adapter.
right?
FYI, if the allocation fails then it assigns the name using default
format i.e. "eth%d".
On Mon, Jan 17, 2022 at 3:17 AM Pavel Skripkin <paskripkin@gmail.com> wrote:
>
> Hi Vihas,
>
> On 1/16/22 22:26, Vihas Mak wrote:
> > rtw_init_netdev_name() calls dev_alloc_name() which allocates the name
> > for the device as per the given name format.
> > It returns a negative err code if the format is invalid. Currently the
> > name format is specified by the module parameter "ifname".
> > Warn the user if "ifname" is invalid.
> >
> > Signed-off-by: Vihas Mak <makvihas@gmail.com>
> > ---
> > drivers/staging/r8188eu/os_dep/usb_intf.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c
> > index 91792dfd3..875815b5e 100644
> > --- a/drivers/staging/r8188eu/os_dep/usb_intf.c
> > +++ b/drivers/staging/r8188eu/os_dep/usb_intf.c
> > @@ -399,7 +399,10 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
> > DBG_88E("can't get autopm:\n");
> >
> > /* alloc dev name after read efuse. */
> > - rtw_init_netdev_name(pnetdev, padapter->registrypriv.ifname);
> > + if (rtw_init_netdev_name(pnetdev, padapter->registrypriv.ifname) < 0) {
> > + DBG_88E("rtw_init_netdev_name failed, ifname:%s\n",
> > + padapter->registrypriv.ifname);
> > + }
> > rtw_macaddr_cfg(padapter->eeprompriv.mac_addr);
> > rtw_init_wifidirect_addrs(padapter, padapter->eeprompriv.mac_addr,
> > padapter->eeprompriv.mac_addr);
>
> rtw_init_netdev_name() has an error message in case of allocation
> failure. It looks like it's better to handle the error normally and pass
> it to caller
>
>
>
>
> With regards,
> Pavel Skripkin
--
Thanks,
Vihas
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: r8188eu: handle rtw_init_netdev_name() failure appropriately
2022-01-16 19:26 [PATCH] staging: r8188eu: handle rtw_init_netdev_name() failure appropriately Vihas Mak
2022-01-16 21:47 ` Pavel Skripkin
@ 2022-01-18 15:07 ` Dan Carpenter
2022-01-20 12:28 ` Vihas Mak
1 sibling, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2022-01-18 15:07 UTC (permalink / raw)
To: Vihas Mak
Cc: Larry.Finger, phil, gregkh, martin, straube.linux, linux-staging,
linux-kernel
On Mon, Jan 17, 2022 at 12:56:11AM +0530, Vihas Mak wrote:
> rtw_init_netdev_name() calls dev_alloc_name() which allocates the name
> for the device as per the given name format.
> It returns a negative err code if the format is invalid. Currently the
> name format is specified by the module parameter "ifname".
> Warn the user if "ifname" is invalid.
>
> Signed-off-by: Vihas Mak <makvihas@gmail.com>
> ---
This doesn't really fix the bug. Better to re-write the error handling.
See my error handling guide here:
https://lore.kernel.org/all/20210831084735.GL12231@kadam/
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: r8188eu: handle rtw_init_netdev_name() failure appropriately
2022-01-18 15:07 ` Dan Carpenter
@ 2022-01-20 12:28 ` Vihas Mak
0 siblings, 0 replies; 5+ messages in thread
From: Vihas Mak @ 2022-01-20 12:28 UTC (permalink / raw)
To: Dan Carpenter
Cc: Larry.Finger, Phillip Potter, Greg KH, martin, straube.linux,
linux-staging, linux-kernel
>> This doesn't really fix the bug. Better to re-write the error handling.
>> See my error handling guide here:
Thanks Dan for the guide. Will submit a v2 soon.
On Tue, Jan 18, 2022 at 8:37 PM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> On Mon, Jan 17, 2022 at 12:56:11AM +0530, Vihas Mak wrote:
> > rtw_init_netdev_name() calls dev_alloc_name() which allocates the name
> > for the device as per the given name format.
> > It returns a negative err code if the format is invalid. Currently the
> > name format is specified by the module parameter "ifname".
> > Warn the user if "ifname" is invalid.
> >
> > Signed-off-by: Vihas Mak <makvihas@gmail.com>
> > ---
>
> This doesn't really fix the bug. Better to re-write the error handling.
> See my error handling guide here:
>
> https://lore.kernel.org/all/20210831084735.GL12231@kadam/
>
> regards,
> dan carpenter
>
--
Thanks,
Vihas
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-01-20 12:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-16 19:26 [PATCH] staging: r8188eu: handle rtw_init_netdev_name() failure appropriately Vihas Mak
2022-01-16 21:47 ` Pavel Skripkin
2022-01-17 4:05 ` Vihas Mak
2022-01-18 15:07 ` Dan Carpenter
2022-01-20 12:28 ` Vihas Mak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).