net: stmmac: Fixing KW errors

- Fixing various types of kw errors.
List of KW
1. Suspicious dereference of pointer
before NULL check at dwmac-qcom-ethqos.c: 1396

2.Suspicious dereference of pointer
before NULL check at dwmac-qcom-ethqos.c: 1354

3.Suspicious dereference of pointer
before NULL check at dwmac-qcom-ethqos.c: 423

4.Suspicious dereference of pointer
before NULL check at dwmac-qcom-ethqos.c: 443

5.Suspicious dereference of pointer
before NULL check at dwmac-qcom-ethqos.c: 1683

6.Uninitialized variable is used at
dwmac-qcom-pps.c: 46.

Change-Id: I3c98c804c0fee2ecc291852e38a104ca12c42dcc
Acked-by: Nagarjuna Chaganti <nchagant@qti.qualcomm.com>
Signed-off-by: Suraj Jaiswal <jsuraj@codeaurora.org>
This commit is contained in:
Suraj Jaiswal 2021-02-08 17:24:29 +05:30
commit 3ed3433704
2 changed files with 29 additions and 17 deletions

View file

@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2018-19, Linaro Limited
// Copyright (c) 2018-19,21 Linaro Limited
#include <linux/module.h>
#include <linux/of.h>
@ -421,8 +421,10 @@ static int qcom_ethqos_add_ipv6addr(struct ip_params *ip_info,
struct net *net = dev_net(dev);
/*For valid IPv6 address*/
if (!net || !net->genl_sock || !net->genl_sock->sk_socket)
if (!net || !net->genl_sock || !net->genl_sock->sk_socket) {
ETHQOSERR("Sock is null, unable to assign ipv6 address\n");
return -EFAULT;
}
if (!net->ipv6.devconf_dflt) {
ETHQOSERR("ipv6.devconf_dflt is null, schedule wq\n");
@ -1342,17 +1344,25 @@ static ssize_t read_phy_reg_dump(struct file *file, char __user *user_buf,
size_t count, loff_t *ppos)
{
struct qcom_ethqos *ethqos = file->private_data;
struct platform_device *pdev;
struct net_device *dev;
struct stmmac_priv *priv;
unsigned int len = 0, buf_len = 2000;
char *buf;
ssize_t ret_cnt;
int phydata = 0;
int i = 0;
struct platform_device *pdev = ethqos->pdev;
struct net_device *dev = platform_get_drvdata(pdev);
struct stmmac_priv *priv = netdev_priv(dev);
if (!ethqos) {
ETHQOSERR("NULL Pointer\n");
return -EINVAL;
}
if (!ethqos || !dev->phydev) {
pdev = ethqos->pdev;
dev = platform_get_drvdata(pdev);
priv = netdev_priv(dev);
if (!dev->phydev) {
ETHQOSERR("NULL Pointer\n");
return -EINVAL;
}
@ -1386,15 +1396,22 @@ static ssize_t read_rgmii_reg_dump(struct file *file,
loff_t *ppos)
{
struct qcom_ethqos *ethqos = file->private_data;
struct platform_device *pdev;
struct net_device *dev;
unsigned int len = 0, buf_len = 2000;
char *buf;
ssize_t ret_cnt;
int rgmii_data = 0;
struct platform_device *pdev = ethqos->pdev;
struct net_device *dev = platform_get_drvdata(pdev);
if (!ethqos) {
ETHQOSERR("NULL Pointer\n");
return -EINVAL;
}
if (!ethqos || !dev->phydev) {
pdev = ethqos->pdev;
dev = platform_get_drvdata(pdev);
if (!dev->phydev) {
ETHQOSERR("NULL Pointer\n");
return -EINVAL;
}
@ -1536,8 +1553,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
ethqos = devm_kzalloc(&pdev->dev, sizeof(*ethqos), GFP_KERNEL);
if (!ethqos) {
ret = -ENOMEM;
goto err_mem;
return -ENOMEM;
}
ethqos->pdev = pdev;

View file

@ -32,18 +32,14 @@ static DECLARE_WAIT_QUEUE_HEAD(avb_class_b_msg_wq);
static int strlcmp(const char *s, const char *t, size_t n)
{
int ret;
while (n-- && *t != '\0') {
if (*s != *t) {
ret = ((unsigned char)*s - (unsigned char)*t);
n = 0;
return ((unsigned char)*s - (unsigned char)*t);
} else {
++s, ++t;
ret = (unsigned char)*s;
}
}
return ret;
return (unsigned char)*s;
}
static void align_target_time_reg(u32 ch, void __iomem *ioaddr,