From patchwork Mon May 11 15:49:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= X-Patchwork-Id: 215651 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6186BC54E8D for ; Mon, 11 May 2020 15:51:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3BFAF206DB for ; Mon, 11 May 2020 15:51:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="gdufEXDG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730582AbgEKPuG (ORCPT ); Mon, 11 May 2020 11:50:06 -0400 Received: from mail-mw2nam12on2062.outbound.protection.outlook.com ([40.107.244.62]:10442 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730563AbgEKPuF (ORCPT ); Mon, 11 May 2020 11:50:05 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lFJh27cAKHZHiuwywCap2fJw7IwwNo1Y1Dsix5bPh+cs+b3w6EPlINUBcraRqv9KoEvIditJ7i/5fVGnJII5VZwrD/fjIfRWpvIp+rN6qQFqE46r6bja9iJEiFeFNm0yi064dqqUjtGviZRG8c/9m6aOEy7+2vfUmLCDqJELEmGCLNngXHnstt7oZC51HZNC3tJUiw3B7Xc8WLMyk2uBnYAWCG7p8pp/gP7cdETle2eMBR2/f8dNkHbb0WPeqdPaadiwJP8FD2gorNH2SwnvkaPTOUeuLpjYQ7md5Tnbn/ybKbiAorT9Sr/5MkNHDMaSG427WvWG/AxOy5UDFEQwQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=C5n0cjqebCL4J+gINvDozGWmeH0y5pJkM7iroi6BcrY=; b=CDKttffmkY7chrbSBq3DltTExCo/R/yA8qRkUqL6cwiqzHztxLn5oUAu5JmV4AJnrA4XcINB4L0LplPSeAWJOAN8YE7Zj3hxYfF2X6zP5JK1UYNpdmzj1E1f2KRyyZGEu96FAt74h+qhIbZmHediHjVrVdRfUUvP9CspDLMFdzGE2zrpdI9Sl0rpDrhLKD6uXqNxhTyeLeb4E8oMUIpN4BBiyc1IPqRBbUF/IwegrnJRds1O+l1JGcPeydVC/Q3MOUx3dVxovAhX5h5axWutCPaBfyFknMRewY8bEQi2kq4qE4CLvCWofBJc2pxojmrHs1gwzcnm/mgAVMf57ZDPAg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=silabs.com; dmarc=pass action=none header.from=silabs.com; dkim=pass header.d=silabs.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silabs.onmicrosoft.com; s=selector2-silabs-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=C5n0cjqebCL4J+gINvDozGWmeH0y5pJkM7iroi6BcrY=; b=gdufEXDGCmIKb1I/sXEXJnjMMEhK50z2E6V1HNlJPFsFTFTFGKnuK/F5DEelebGvr+T5/DFwdcHRetp/VjlgzbNZNMgrk07hPTmHuR9gvaVU5LtEfYw3pGfPv52UZNv4bkhrdfDj0xxicXqyAihl8lVY3H+ygjjJV8K+0MjE3G4= Authentication-Results: driverdev.osuosl.org; dkim=none (message not signed) header.d=none; driverdev.osuosl.org; dmarc=none action=none header.from=silabs.com; Received: from MWHPR11MB1775.namprd11.prod.outlook.com (2603:10b6:300:10e::14) by MWHPR11MB1968.namprd11.prod.outlook.com (2603:10b6:300:113::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.26; Mon, 11 May 2020 15:49:59 +0000 Received: from MWHPR11MB1775.namprd11.prod.outlook.com ([fe80::e055:3e6d:ff4:56da]) by MWHPR11MB1775.namprd11.prod.outlook.com ([fe80::e055:3e6d:ff4:56da%5]) with mapi id 15.20.2979.033; Mon, 11 May 2020 15:49:59 +0000 From: Jerome Pouiller To: devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Kalle Valo , "David S . Miller" , =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= Subject: [PATCH 07/17] staging: wfx: fix endianness of hif_req_read_mib fields Date: Mon, 11 May 2020 17:49:20 +0200 Message-Id: <20200511154930.190212-8-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200511154930.190212-1-Jerome.Pouiller@silabs.com> References: <20200511154930.190212-1-Jerome.Pouiller@silabs.com> X-ClientProxiedBy: SN6PR2101CA0026.namprd21.prod.outlook.com (2603:10b6:805:106::36) To MWHPR11MB1775.namprd11.prod.outlook.com (2603:10b6:300:10e::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc-42.silabs.com (82.67.86.106) by SN6PR2101CA0026.namprd21.prod.outlook.com (2603:10b6:805:106::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.2 via Frontend Transport; Mon, 11 May 2020 15:49:57 +0000 X-Mailer: git-send-email 2.26.2 X-Originating-IP: [82.67.86.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4e703613-7df4-4c51-b5bc-08d7f5c2f5c0 X-MS-TrafficTypeDiagnostic: MWHPR11MB1968: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:163; X-Forefront-PRVS: 04004D94E2 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: I86yrXcvOI6UWTAuDFFcdXP3lGdvgs/LeG6Xt7J4d07xhK1+gZg1/TB8o3m8yVYOMzmHSbQyt9tT2Bct/Rqenk3gqM0uLr6shZD+Mdn9TJtP/R1/imhS1JFgy5izzULp3AUwPcYfyw0r3129BtvqN0pgbIAp1+6RjIiNjTg3QGZSayGoqRZB7ontoHOguYF4PSj+tnzAH/jXDJsQCg4+WFKs5A6gVOyvQRuJLZerZti4fD9UJmBZdtrSRl6ym88AwBUI+oMG1wVjhQJYr6sOzGedsyuAQFGkC2iHnzXHJzNLEpIg55Cj+0Q107DQwkFWTJLB7zqh1Sn/QMuSxjvoVhHJRFD0jVb+gHkx3fhfCO5p8w5lj8U7un10CZW87EOJ8Pi5N4z5iFmAxmO3oUYh8hdkkmZ627EOO3i/CZL/ZGLj9fCoxDQvaOY5ohZLGCieiEV9GxOa1BmELNFdVnpJZvYpbKC9ElZ4zE8urZmd3mC3sgmECBeuyrPQ0B69Wp0niL51uDTr33M5ZJMANc/Qlw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR11MB1775.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(39850400004)(346002)(136003)(396003)(376002)(366004)(33430700001)(186003)(52116002)(86362001)(316002)(5660300002)(7696005)(6486002)(33440700001)(478600001)(54906003)(6666004)(4326008)(107886003)(66574014)(36756003)(16526019)(26005)(8936002)(956004)(2616005)(8676002)(1076003)(66476007)(66946007)(66556008)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: /LkFsSB071M+5tohCfR2PMypGS06CAbq84axijkH1NLl/URkKEAHvHCHLoy3BlX86T999MXvUvu1o68dUfGoOi2Ip4PCyKelOuRryyHLkCBWF3GwxIOqAYUWIJLNMONJ3ZAtGM7P+MdGjrnOqHfO5rUdfu/wFQ+Kf0Gmjo68/zN/iEJYFfKzRFGejghWRudnPU2y+WoBqL/cwN/soIY+oJcxuzC1Akls1unSxkexrNMXED3Ewhao/9I/d5OtyNmHx3x5OTutb8MW6NtsjwcazQDkkZLr2qFWXyCCBfOm1ncwmMFS801O/mn3x1h8gOIlX94C7Jnr2WCHJuXRSiib1IEupeGR5iEG2c32X+I39EL56QRWEtDAZebrpjcCyxJKV06lUx81rNI4K0tq1h0RtKGObUeON/t7pcSdzTDJjPZnSOhuNf/t3qdV/RfD4mnTCB49GF/pjRGrVAZswSzZcJpFTNc9b8j9KZGRBA0xDJU= X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e703613-7df4-4c51-b5bc-08d7f5c2f5c0 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2020 15:49:59.5000 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 54dbd822-5231-4b20-944d-6f4abcd541fb X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: MWC3QhMVS0nPeV7Uaeqq7RYO+MBT4k00FuEMhUuvYAH8/yRDdA5m4NTcucssSwFsWiZNiSnqtcnMvDS8AXw8LA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1968 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Jérôme Pouiller The structs hif_{req,cnf}_read_mib contain only little endian values. Thus, it is necessary to fix byte ordering before to use them. Especially, sparse detected wrong accesses to fields mib_id and length. Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/hif_tx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/wfx/hif_tx.c b/drivers/staging/wfx/hif_tx.c index 58013c019192..490a9de54faf 100644 --- a/drivers/staging/wfx/hif_tx.c +++ b/drivers/staging/wfx/hif_tx.c @@ -189,17 +189,17 @@ int hif_read_mib(struct wfx_dev *wdev, int vif_id, u16 mib_id, wfx_fill_header(hif, vif_id, HIF_REQ_ID_READ_MIB, sizeof(*body)); ret = wfx_cmd_send(wdev, hif, reply, buf_len, false); - if (!ret && mib_id != reply->mib_id) { + if (!ret && mib_id != le16_to_cpu(reply->mib_id)) { dev_warn(wdev->dev, "%s: confirmation mismatch request\n", __func__); ret = -EIO; } if (ret == -ENOMEM) - dev_err(wdev->dev, - "buffer is too small to receive %s (%zu < %d)\n", - get_mib_name(mib_id), val_len, reply->length); + dev_err(wdev->dev, "buffer is too small to receive %s (%zu < %d)\n", + get_mib_name(mib_id), val_len, + le16_to_cpu(reply->length)); if (!ret) - memcpy(val, &reply->mib_data, reply->length); + memcpy(val, &reply->mib_data, le16_to_cpu(reply->length)); else memset(val, 0xFF, val_len); kfree(hif);