* [PATCH] staging: r8188eu: Remove goto to no-op exit label @ 2022-04-01 18:35 Fabio M. De Francesco 2022-04-01 20:41 ` Ira Weiny 0 siblings, 1 reply; 6+ messages in thread From: Fabio M. De Francesco @ 2022-04-01 18:35 UTC (permalink / raw) To: Larry Finger, Phillip Potter, Greg Kroah-Hartman, linux-staging, linux-kernel, outreachy Cc: Fabio M. De Francesco In function rtw_free_netdev() there are two "goto" jumps to a no-op exit label called "RETURN". Remove the label and return in line. Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com> --- drivers/staging/r8188eu/os_dep/osdep_service.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index 7a6fcc96081a..d680bfba7f5d 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -117,18 +117,15 @@ void rtw_free_netdev(struct net_device *netdev) struct rtw_netdev_priv_indicator *pnpi; if (!netdev) - goto RETURN; + return; pnpi = netdev_priv(netdev); if (!pnpi->priv) - goto RETURN; + return; vfree(pnpi->priv); free_netdev(netdev); - -RETURN: - return; } int rtw_change_ifname(struct adapter *padapter, const char *ifname) -- 2.34.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] staging: r8188eu: Remove goto to no-op exit label 2022-04-01 18:35 [PATCH] staging: r8188eu: Remove goto to no-op exit label Fabio M. De Francesco @ 2022-04-01 20:41 ` Ira Weiny 2022-04-02 10:13 ` Fabio M. De Francesco 2022-04-04 9:59 ` Dan Carpenter 0 siblings, 2 replies; 6+ messages in thread From: Ira Weiny @ 2022-04-01 20:41 UTC (permalink / raw) To: Fabio M. De Francesco Cc: Larry Finger, Phillip Potter, Greg Kroah-Hartman, linux-staging, linux-kernel, outreachy On Fri, Apr 01, 2022 at 08:35:13PM +0200, Fabio M. De Francesco wrote: > In function rtw_free_netdev() there are two "goto" jumps to a no-op exit > label called "RETURN". Remove the label and return in line. Thanks for the patch! However, A good commit message lists the why and what of a change. I don't see a why for this commit? FWIW (For what it's worth) I know of a couple of good reasons for this change but you should get in the habit of putting that in the commit message. Even for obvious things like this. Anyway, I think this patch can stand on it's own with an updated commit message. However, see below... > > Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com> > --- > drivers/staging/r8188eu/os_dep/osdep_service.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c > index 7a6fcc96081a..d680bfba7f5d 100644 > --- a/drivers/staging/r8188eu/os_dep/osdep_service.c > +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c > @@ -117,18 +117,15 @@ void rtw_free_netdev(struct net_device *netdev) > struct rtw_netdev_priv_indicator *pnpi; > > if (!netdev) > - goto RETURN; > + return; > > pnpi = netdev_priv(netdev); > > if (!pnpi->priv) > - goto RETURN; > + return; This does not look right. If netdev is not NULL why does this function skip free_netdev()? Fabio could you follow up with Larry and/or Phillip and see why the code does this? To me it looks like a potential bug. Thanks! Ira > > vfree(pnpi->priv); > free_netdev(netdev); > - > -RETURN: > - return; > } > > int rtw_change_ifname(struct adapter *padapter, const char *ifname) > -- > 2.34.1 > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] staging: r8188eu: Remove goto to no-op exit label 2022-04-01 20:41 ` Ira Weiny @ 2022-04-02 10:13 ` Fabio M. De Francesco 2022-04-02 11:45 ` Martin Kaiser 2022-04-04 9:59 ` Dan Carpenter 1 sibling, 1 reply; 6+ messages in thread From: Fabio M. De Francesco @ 2022-04-02 10:13 UTC (permalink / raw) To: Ira Weiny, Greg Kroah-Hartman Cc: Larry Finger, Phillip Potter, linux-staging, linux-kernel, outreachy On venerd? 1 aprile 2022 22:41:40 CEST Ira Weiny wrote: > On Fri, Apr 01, 2022 at 08:35:13PM +0200, Fabio M. De Francesco wrote: > > In function rtw_free_netdev() there are two "goto" jumps to a no-op exit > > label called "RETURN". Remove the label and return in line. > > Thanks for the patch! However, A good commit message lists the why and what of > a change. I don't see a why for this commit? Yes I forgot the "why" :( I'll rework the commit message for v2. > > FWIW (For what it's worth) I know of a couple of good reasons for this change > but you should get in the habit of putting that in the commit message. Even > for obvious things like this. > > Anyway, I think this patch can stand on it's own with an updated commit > message. However, see below... > > > > > Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com> > > --- > > drivers/staging/r8188eu/os_dep/osdep_service.c | 7 ++----- > > 1 file changed, 2 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c > > index 7a6fcc96081a..d680bfba7f5d 100644 > > --- a/drivers/staging/r8188eu/os_dep/osdep_service.c > > +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c > > @@ -117,18 +117,15 @@ void rtw_free_netdev(struct net_device *netdev) > > struct rtw_netdev_priv_indicator *pnpi; > > > > if (!netdev) > > - goto RETURN; > > + return; Actually this function doesn't need to test for a valid "netdev". There are only two callers of this function (they are in os_dep/usb_intf.c) and they already test the pointer soon before calling rtw_free_netdev(). Therefore, I'll remove the test for a valid "netdev" and (obviously) the code has no more need to return at that point in function. > > > > pnpi = netdev_priv(netdev); > > > > if (!pnpi->priv) > > - goto RETURN; > > + return; I cannot see how pnpi->priv might ever be NULL. Pavel Skripkin made me notice that "in rtw_alloc_etherdev() (I can confirm this information because now I've just read the code), if pnpi->priv allocation fails, then netdev will be just freed.". If "netdev" is already free, this function is never called. Therefore, I'll remove this test too. > This does not look right. If netdev is not NULL why does this function skip > free_netdev()? After the two removals I've talked about above, the code will always call vfree(pnpi->priv) and then free_netdev(netdev). Therefore, the code won't anymore skip free_netdev() and the bug is avoided. > > Fabio could you follow up with Larry and/or Phillip and see why the code does > this? To me it looks like a potential bug. > > Thanks! > Ira > > > > > vfree(pnpi->priv); > > free_netdev(netdev); > > - > > -RETURN: > > - return; > > } > > > > int rtw_change_ifname(struct adapter *padapter, const char *ifname) > > -- > > 2.34.1 > > > This is how I think to rework rtw_free_netdev(): void rtw_free_netdev(struct net_device *netdev) { struct rtw_netdev_priv_indicator *pnpi = netdev_priv(netdev); vfree(pnpi->priv); free_netdev(netdev); } Am I missing something? @Greg: please discard this patch; I'll send another that has the purpose to rework rtw_free_netdev() as I showed above for the purpose to avoid redundant tests and avoid the potential skipping of free_netdev() (as Ira has correctly noted, currently we have a bug). Thanks, Fabio ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] staging: r8188eu: Remove goto to no-op exit label 2022-04-02 10:13 ` Fabio M. De Francesco @ 2022-04-02 11:45 ` Martin Kaiser 2022-04-02 13:22 ` Fabio M. De Francesco 0 siblings, 1 reply; 6+ messages in thread From: Martin Kaiser @ 2022-04-02 11:45 UTC (permalink / raw) To: Fabio M. De Francesco Cc: Ira Weiny, Greg Kroah-Hartman, Larry Finger, Phillip Potter, linux-staging, linux-kernel, outreachy Thus wrote Fabio M. De Francesco (fmdefrancesco@gmail.com): > > > pnpi = netdev_priv(netdev); > > > if (!pnpi->priv) > > > - goto RETURN; > > > + return; > I cannot see how pnpi->priv might ever be NULL. Even if pnpi->priv was NULL, we wouldn't need the check. It's ok to call vfree(NULL). > After the two removals I've talked about above, the code will always call > vfree(pnpi->priv) and then free_netdev(netdev). That makes sense. Best regards, Martin ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] staging: r8188eu: Remove goto to no-op exit label 2022-04-02 11:45 ` Martin Kaiser @ 2022-04-02 13:22 ` Fabio M. De Francesco 0 siblings, 0 replies; 6+ messages in thread From: Fabio M. De Francesco @ 2022-04-02 13:22 UTC (permalink / raw) To: Martin Kaiser Cc: Ira Weiny, Greg Kroah-Hartman, Larry Finger, Phillip Potter, linux-staging, linux-kernel, outreachy On sabato 2 aprile 2022 13:45:33 CEST Martin Kaiser wrote: > Thus wrote Fabio M. De Francesco (fmdefrancesco@gmail.com): > > > > > pnpi = netdev_priv(netdev); > > > > > if (!pnpi->priv) > > > > - goto RETURN; > > > > + return; > > > I cannot see how pnpi->priv might ever be NULL. > > Even if pnpi->priv was NULL, we wouldn't need the check. It's ok to call > vfree(NULL). > > > After the two removals I've talked about above, the code will always call > > vfree(pnpi->priv) and then free_netdev(netdev). > > That makes sense. > > Best regards, > Martin > Hi Martin, Thanks for reminding to me that a vfree() on a NULL pointer is a no-op. I'm going to submit a new patch with the purpose to re-work rtw_free_netdev(). Thanks again, Fabio ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] staging: r8188eu: Remove goto to no-op exit label 2022-04-01 20:41 ` Ira Weiny 2022-04-02 10:13 ` Fabio M. De Francesco @ 2022-04-04 9:59 ` Dan Carpenter 1 sibling, 0 replies; 6+ messages in thread From: Dan Carpenter @ 2022-04-04 9:59 UTC (permalink / raw) To: Ira Weiny Cc: Fabio M. De Francesco, Larry Finger, Phillip Potter, Greg Kroah-Hartman, linux-staging, linux-kernel, outreachy On Fri, Apr 01, 2022 at 01:41:40PM -0700, Ira Weiny wrote: > On Fri, Apr 01, 2022 at 08:35:13PM +0200, Fabio M. De Francesco wrote: > > In function rtw_free_netdev() there are two "goto" jumps to a no-op exit > > label called "RETURN". Remove the label and return in line. > > Thanks for the patch! However, A good commit message lists the why and what of > a change. I don't see a why for this commit? People, stop belly aching about commit messages. "Delete no-op goto" is sufficient justification. regards, dan carpenter ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-04-04 10:00 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-04-01 18:35 [PATCH] staging: r8188eu: Remove goto to no-op exit label Fabio M. De Francesco 2022-04-01 20:41 ` Ira Weiny 2022-04-02 10:13 ` Fabio M. De Francesco 2022-04-02 11:45 ` Martin Kaiser 2022-04-02 13:22 ` Fabio M. De Francesco 2022-04-04 9:59 ` Dan Carpenter
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.