Re: [PATCH] wifi: mt76: mt7996: prevent uninit return in mt7996_mac_sta_add_links

Dan Carpenter
2025-03-22T10:19:51Z

On Sat, Mar 22, 2025 at 11:01:18AM +0100, Markus Elfring wrote:
> …
> > +++ b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
> > @@ -998,16 +998,22 @@ mt7996_mac_sta_add_links(struct mt7996_dev *dev, struct ieee80211_vif *vif,
> > continue;
> >
> > link_conf = link_conf_dereference_protected(vif, link_id);
> > - if (!link_conf)
> > + if (!link_conf) {
> > + err = -EINVAL;
> > goto error_unlink;
> > + }
> >
> > link = mt7996_vif_link(dev, vif, link_id);
> > - if (!link)
> > + if (!link) {
> > + err = -EINVAL;
> > goto error_unlink;
> > + }
> …
>
> I suggest to avoid such repeated error code assignments.
> Can an additional label be applied instead for this purpose?

Maintainers get the final vote but generally when someone is doing
the work they get to decide.

I would say that generally the way that Qasim did it is normally
more readable and more future proof.

regards
dan carpenter