lkml.org 
[lkml]   [2021]   [Jul]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.13 011/266] net: pch_gbe: Use proper accessors to BE data in pch_ptp_match()
    Date
    From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

    [ Upstream commit 443ef39b499cc9c6635f83238101f1bb923e9326 ]

    Sparse is not happy about handling of strict types in pch_ptp_match():

    .../pch_gbe_main.c:158:33: warning: incorrect type in argument 2 (different base types)
    .../pch_gbe_main.c:158:33: expected unsigned short [usertype] uid_hi
    .../pch_gbe_main.c:158:33: got restricted __be16 [usertype]
    .../pch_gbe_main.c:158:45: warning: incorrect type in argument 3 (different base types)
    .../pch_gbe_main.c:158:45: expected unsigned int [usertype] uid_lo
    .../pch_gbe_main.c:158:45: got restricted __be32 [usertype]
    .../pch_gbe_main.c:158:56: warning: incorrect type in argument 4 (different base types)
    .../pch_gbe_main.c:158:56: expected unsigned short [usertype] seqid
    .../pch_gbe_main.c:158:56: got restricted __be16 [usertype]

    Fix that by switching to use proper accessors to BE data.

    Reported-by: kernel test robot <lkp@intel.com>
    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Tested-by: Flavio Suligoi <f.suligoi@asem.it>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    .../ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 19 ++++++-------------
    1 file changed, 6 insertions(+), 13 deletions(-)

    diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
    index 3dc29b282a88..45b9ba1ec760 100644
    --- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
    +++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
    @@ -108,7 +108,7 @@ static int pch_ptp_match(struct sk_buff *skb, u16 uid_hi, u32 uid_lo, u16 seqid)
    {
    u8 *data = skb->data;
    unsigned int offset;
    - u16 *hi, *id;
    + u16 hi, id;
    u32 lo;

    if (ptp_classify_raw(skb) == PTP_CLASS_NONE)
    @@ -119,14 +119,11 @@ static int pch_ptp_match(struct sk_buff *skb, u16 uid_hi, u32 uid_lo, u16 seqid)
    if (skb->len < offset + OFF_PTP_SEQUENCE_ID + sizeof(seqid))
    return 0;

    - hi = (u16 *)(data + offset + OFF_PTP_SOURCE_UUID);
    - id = (u16 *)(data + offset + OFF_PTP_SEQUENCE_ID);
    + hi = get_unaligned_be16(data + offset + OFF_PTP_SOURCE_UUID + 0);
    + lo = get_unaligned_be32(data + offset + OFF_PTP_SOURCE_UUID + 2);
    + id = get_unaligned_be16(data + offset + OFF_PTP_SEQUENCE_ID);

    - memcpy(&lo, &hi[1], sizeof(lo));
    -
    - return (uid_hi == *hi &&
    - uid_lo == lo &&
    - seqid == *id);
    + return (uid_hi == hi && uid_lo == lo && seqid == id);
    }

    static void
    @@ -136,7 +133,6 @@ pch_rx_timestamp(struct pch_gbe_adapter *adapter, struct sk_buff *skb)
    struct pci_dev *pdev;
    u64 ns;
    u32 hi, lo, val;
    - u16 uid, seq;

    if (!adapter->hwts_rx_en)
    return;
    @@ -152,10 +148,7 @@ pch_rx_timestamp(struct pch_gbe_adapter *adapter, struct sk_buff *skb)
    lo = pch_src_uuid_lo_read(pdev);
    hi = pch_src_uuid_hi_read(pdev);

    - uid = hi & 0xffff;
    - seq = (hi >> 16) & 0xffff;
    -
    - if (!pch_ptp_match(skb, htons(uid), htonl(lo), htons(seq)))
    + if (!pch_ptp_match(skb, hi, lo, hi >> 16))
    goto out;

    ns = pch_rx_snap_read(pdev);
    --
    2.30.2


    \
     
     \ /
      Last update: 2021-07-15 21:39    [W:4.410 / U:0.004 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site