s390/net: Cleanup some code checker findings
Subsystems (4)
Alexandra Winter
maintainercover s390/net: Cleanup some code checker findings
clean up smatch findings in legacy code. I was not able to provoke any real failures on my systems, but other hardware reactions, timing conditions or compiler output, may cause failures.
There are still 2 smatch warnings left in s390/net:
drivers/s390/net/ctcm_main.c:1326 add_channel() warn: missing error code 'rc' This one is a false positive.
drivers/s390/net/netiucv.c:1355 netiucv_check_user() warn: argument 3 to %02x specifier has type 'char' Postponing this one, need to better understand string handling in iucv.
There are several sparse warnings left in ctcm, like:drivers/s390/net/ctcm_fsms.c:573:9: warning: context imbalance in 'ctcm_chx_setmode' - different lock contexts for basic block Those are mentioned in the source, no plan to rework.
Alexandra Winter (3):
s390/ctcm: fix variable dereferenced before check s390/ctcm: fix potential memory leak s390/lcs: fix variable dereferenced before check
drivers/s390/net/ctcm_mpc.c | 6 +----- drivers/s390/net/ctcm_sysfs.c | 5 +++-- drivers/s390/net/lcs.c | 7 ++++--- 3 files changed, 8 insertions(+), 10 deletions(-)
Signature · 1 line
2.32.0
Alexandra Winter
maintainerPATCH 3/3 s390/lcs: fix variable dereferenced before check
smatch complains aboutdrivers/s390/net/lcs.c:1741 lcs_get_control() warn: variable dereferenced before check 'card->dev' (see line 1739)
--- drivers/s390/net/lcs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/s390/net/lcs.c +4 -3
@@ -1736,10 +1736,11 @@ lcs_get_control(struct lcs_card *card, struct lcs_cmd *cmd)lcs_schedule_recovery (card);break ;case LCS_CMD_STOPLAN : -pr_warn ("Stoplan for %s initiated by LGW\n" , - card->dev->name); -if (card->dev) +if (card->dev) { +pr_warn ("Stoplan for %s initiated by LGW\n" , + card->dev->name);netif_carrier_off (card->dev); + }break ;default :LCS_DBF_TEXT (5 , trace,"noLGWcmd" );
Signature · 1 line
2.32.0
Alexandra Winter
maintainerPATCH 1/3 s390/ctcm: fix variable dereferenced before check
In reply to Alexandra WinterFound by cppcheck and smatch.
smatch complains aboutdrivers/s390/net/ctcm_sysfs.c:43 ctcm_buffer_write() warn: variable dereferenced before check 'priv' (see line 42)
--- drivers/s390/net/ctcm_sysfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/s390/net/ctcm_sysfs.c +3 -2
@@ -39,11 +39,12 @@ static ssize_t ctcm_buffer_write(struct device *dev,struct ctcm_priv *priv =dev_get_drvdata (dev);int rc; - ndev = priv->channel[CTCM_READ ]->netdev; -if (!(priv && priv->channel[CTCM_READ ] && ndev)) { +if (!(priv && priv->channel[CTCM_READ ] && + priv->channel[CTCM_READ ]->netdev)) {CTCM_DBF_TEXT (SETUP ,CTC_DBF_ERROR ,"bfnondev" );return -ENODEV ; } + ndev = priv->channel[CTCM_READ ]->netdev; rc =kstrtouint (buf,0 , &bs1);if (rc)
Signature · 1 line
2.32.0
Alexandra Winter
maintainerPATCH 2/3 s390/ctcm: fix potential memory leak
In reply to Alexandra Wintersmatch complains aboutdrivers/s390/net/ctcm_mpc.c:1210 ctcmpc_unpack_skb() warn: possible memory leak of 'mpcginfo'
mpc_action_discontact() did not free mpcginfo. Consolidate the freeing in ctcmpc_unpack_skb().
--- drivers/s390/net/ctcm_mpc.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/s390/net/ctcm_mpc.c +1 -5
@@ -626,8 +626,6 @@ static void mpc_rcvd_sweep_resp(struct mpcg_info *mpcginfo)ctcm_clear_busy_do (dev); } -kfree (mpcginfo); -return ; }
@@ -1192,10 +1190,10 @@ static void ctcmpc_unpack_skb(struct channel *ch, struct sk_buff *pskb) CTCM_FUNTAIL, dev->name); priv->stats.rx_dropped++;/* mpcginfo only used for non-data transfers */ -kfree (mpcginfo);if (do_debug_data)ctcmpc_dump_skb (pskb,-8 ); } +kfree (mpcginfo); } done:
@@ -1977,7 +1975,6 @@ static void mpc_action_rcvd_xid0(fsm_instance *fsm, int event, void *arg) }break ; } -kfree (mpcginfo); CTCM_PR_DEBUG("ctcmpc:%s() %s xid2:%i xid7:%i xidt_p2:%i \n", __func__, ch->id, grp->outstanding_xid2,
@@ -2038,7 +2035,6 @@ static void mpc_action_rcvd_xid7(fsm_instance *fsm, int event, void *arg)mpc_validate_xid (mpcginfo);break ; } -kfree (mpcginfo);return ; }
Signature · 1 line
2.32.0
This series was applied to netdev/net.git (master) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net.git (master) by David S. Miller <[email protected]>:
Quoted 10 lines · On Tue, 10 May 2022 09:05:05 +0200 you wrote:
clean up smatch findings in legacy code. I was not able to provoke any real failures on my systems, but other hardware reactions, timing conditions or compiler output, may cause failures.
There are still 2 smatch warnings left in s390/net:
drivers/s390/net/ctcm_main.c:1326add_channel()warn: missing error code 'rc' This one is a false positive.[...]
Here is the summary with links:
- [net,1/3] s390/ctcm: fix variable dereferenced before check
https://git.kernel.org/netdev/net/c/2c50c6867c85 - [net,2/3] s390/ctcm: fix potential memory leak https://git.kernel.org/netdev/net/c/0c0b20587b9f - [net,3/3] s390/lcs: fix variable dereferenced before check https://git.kernel.org/netdev/net/c/671bb35c8e74
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html