From: Kevin Hao <kexin....@windriver.com>

The 'gcl' is a pointer, so 'gcl + i' always evaluate as 'true'. And the
memory pointed by 'gcl' is allocated based on the
sgiadmin.admin.control_list_length, so it makes no sense to recheck the
out of bounds access. Drop these codes to fix the following build
warning:
  net/tsn/genl_tsn.c:1684:21: warning: the comparison will always evaluate as 
‘true’ for the pointer operand in ‘gcl + (sizetype)((long unsigned int)i * 12)’ 
must not be NULL [-Waddress]
   1684 |                 if (!(gcl + i)) {
        |                     ^

Signed-off-by: Kevin Hao <kexin....@windriver.com>
---
 net/tsn/genl_tsn.c | 14 --------------
 1 file changed, 14 deletions(-)

diff --git a/net/tsn/genl_tsn.c b/net/tsn/genl_tsn.c
index a1aec189f846..1bdb4a01ce8f 100644
--- a/net/tsn/genl_tsn.c
+++ b/net/tsn/genl_tsn.c
@@ -1681,13 +1681,6 @@ static int cmd_qci_sgi_get(struct genl_info *info)
                s8 ipv;
                u32 ti, omax;
 
-               if (!(gcl + i)) {
-                       pr_err("error: list count too big\n");
-                       ret = -EINVAL;
-                       kfree(sgiadmin.admin.gcl);
-                       goto err;
-               }
-
                /* Adminastration entry */
                sglattr = nla_nest_start_noflag(rep_skb,
                                                TSN_SGI_ATTR_CTRL_GCLENTRY);
@@ -1877,13 +1870,6 @@ static int cmd_qci_sgi_status_get(struct genl_info *info)
                s8 ipv;
                u32 ti, omax;
 
-               if (!(gcl + i)) {
-                       pr_err("error: list count too big\n");
-                       ret = -EINVAL;
-                       kfree(sgistat.oper.gcl);
-                       goto err;
-               }
-
                /* Operation entry */
                sglattr = nla_nest_start_noflag(rep_skb,
                                                TSN_SGI_ATTR_CTRL_GCLENTRY);
-- 
2.39.2

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#12759): 
https://lists.yoctoproject.org/g/linux-yocto/message/12759
Mute This Topic: https://lists.yoctoproject.org/mt/99523723/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to