Skip to content

Commit

Permalink
s390/ctcm: fix variable dereferenced before check
Browse files Browse the repository at this point in the history
[ Upstream commit 2c50c68 ]

Found by cppcheck and smatch.
smatch complains about
drivers/s390/net/ctcm_sysfs.c:43 ctcm_buffer_write() warn: variable dereferenced before check 'priv' (see line 42)

Fixes: 3c09e26 ("ctcm: rename READ/WRITE defines to avoid redefinitions")
Reported-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Alexandra Winter <wintera@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
SandyWinter authored and gregkh committed May 18, 2022
1 parent cc71c9f commit 5497f87
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/s390/net/ctcm_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5497f87

Please sign in to comment.