From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 111B8258A for ; Sun, 17 Apr 2022 17:54:49 +0000 (UTC) Received: by mail-ej1-f45.google.com with SMTP id u15so23465582ejf.11 for ; Sun, 17 Apr 2022 10:54:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sZTBfR/A89syNfUStFLmnUWCQR/KrbeiEyXxR04D+i4=; b=JbNAEqTXiQowm2n17xTXw3p55q/678/g4P2W8R2+Gq8DZeXcdqZKHqBnon1GuG6Rco e+gzkl0dUhLAp/TcbnXCaju0oWLkNLeHKiTQrWVZ2ORSxBWhtPvMQgBFM7qmM7hsgsP0 WdADsG+v+sECo5fkpt0CapJF6C8QFMK4XmpS+2m1fcqEl9vbDMuIKrhBQk+KQ24OL21U PlbPKzuwYFpsSowSiSBIusykAvZUxwvCaxt5ihrYNeimVQO4X+1reeb1I5oHP+F8aFFk mCKF8hm0HWf+WVYEZnunVTD9eLk/rVRJRUoeMRiMp/IW64KXsdbvjeAPr/Mnc3yl59SF ID8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sZTBfR/A89syNfUStFLmnUWCQR/KrbeiEyXxR04D+i4=; b=QfCszePgLthpzFoBljbUM2QWh6pkuP/XyO6EnqSuUcHKdCvNgV2HE6CyQ7fqllvhqY jjpA8FE93sso2/I+ZVL/Re4R/yaDO8ylWZFSJWBWr2juOroDJ1eq9T7GyZfd5naBYCjB skoo7DJPUFK9v7l2SSzbKLTFs1fJa47shpCg7Se4GWN2ZpWDXGkmM+l79ey1ggMFkVQ+ uwF1AHpEXLlUIku1RfK6fHah+NMx7c0JUOiK8sWtbOtbzQld3s3eDeGC4OOb7qiaDFnb WFeabvdhGrHdPL7E7kOKIGe6pSNJRsPSWghVyLP4tSIl8/ExCzOuaLRVFRguMGId7gjj eZmg== X-Gm-Message-State: AOAM530mVVaira2467A3CyUZQx/0w7F487ag1bCNlan6X8kYQ1JiG1Nx rdiONGDtt9CIzp2zb1ox9kqnTC3JSeM= X-Google-Smtp-Source: ABdhPJwXoFfnrFhj0GsJ8c2wFNj++cwxFiLjiiIn68WECW8SJS8vyxTlSYWX4RZpIp6goCLoEzlxXA== X-Received: by 2002:a17:907:948b:b0:6d8:27f8:ab4a with SMTP id dm11-20020a170907948b00b006d827f8ab4amr6363899ejc.39.1650218088398; Sun, 17 Apr 2022 10:54:48 -0700 (PDT) Received: from localhost.localdomain (ip5f5abba5.dynamic.kabel-deutschland.de. [95.90.187.165]) by smtp.gmail.com with ESMTPSA id jw12-20020a17090776ac00b006e87137194esm3719409ejc.150.2022.04.17.10.54.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Apr 2022 10:54:47 -0700 (PDT) From: Michael Straube To: gregkh@linuxfoundation.org Cc: Larry.Finger@lwfinger.net, phil@philpotter.co.uk, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Michael Straube Subject: [PATCH v4 1/8] staging: r8188eu: fix struct rt_firmware_hdr Date: Sun, 17 Apr 2022 19:54:34 +0200 Message-Id: <20220417175441.13830-2-straube.linux@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220417175441.13830-1-straube.linux@gmail.com> References: <20220417175441.13830-1-straube.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The size of struct rt_firmware_hdr is 36 bytes. $ pahole -C rt_firmware_hdr drivers/staging/r8188eu/r8188eu.o struct rt_firmware_hdr { __le16 Signature; /* 0 2 */ u8 Category; /* 2 1 */ u8 Function; /* 3 1 */ __le16 Version; /* 4 2 */ u8 Subversion; /* 6 1 */ /* XXX 1 byte hole, try to pack */ u16 Rsvd1; /* 8 2 */ u8 Month; /* 10 1 */ u8 Date; /* 11 1 */ u8 Hour; /* 12 1 */ u8 Minute; /* 13 1 */ __le16 RamCodeSize; /* 14 2 */ u8 Foundry; /* 16 1 */ u8 Rsvd2; /* 17 1 */ /* XXX 2 bytes hole, try to pack */ __le32 SvnIdx; /* 20 4 */ u32 Rsvd3; /* 24 4 */ u32 Rsvd4; /* 28 4 */ u32 Rsvd5; /* 32 4 */ /* size: 36, cachelines: 1, members: 17 */ /* sum members: 33, holes: 2, sum holes: 3 */ /* last cacheline: 36 bytes */ }; But the header in the firmware file is only 32 bytes long. The hexdump of rtl8188eufw.bin shows that the field Rsvd1 should be u8 instead of __le16. OFFSET rtl8188eufw.bin ----------------------------------------------------------- 0x00000000 E1 88 10 00 0B 00 01 00 01 21 11 27 30 36 00 00 0x00000010 2D 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x00000000 E1 88 10 00 0B 00 01 00 01 21 11 27 30 36 00 00 ^ ^ ^ ^ ^ ^ Subversion Rsvd1 Month Date Hour Minute With the change of field Rsvd1 from __le16 to u8 the structure has the correct size 32. $ pahole -C rt_firmware_hdr drivers/staging/r8188eu/r8188eu.o struct rt_firmware_hdr { __le16 Signature; /* 0 2 */ u8 Category; /* 2 1 */ u8 Function; /* 3 1 */ __le16 Version; /* 4 2 */ u8 Subversion; /* 6 1 */ u8 Rsvd1; /* 7 1 */ u8 Month; /* 8 1 */ u8 Date; /* 9 1 */ u8 Hour; /* 10 1 */ u8 Minute; /* 11 1 */ __le16 RamCodeSize; /* 12 2 */ u8 Foundry; /* 14 1 */ u8 Rsvd2; /* 15 1 */ __le32 SvnIdx; /* 16 4 */ u32 Rsvd3; /* 20 4 */ u32 Rsvd4; /* 24 4 */ u32 Rsvd5; /* 28 4 */ /* size: 32, cachelines: 1, members: 17 */ /* last cacheline: 32 bytes */ The wrong size had no effect because the header size is hardcoded to 32 where it is used in the code and the fields after Subversion are not used. Fixes: 7884fc0a1473 ("staging: r8188eu: introduce new include dir for RTL8188eu driver") Signed-off-by: Michael Straube --- v4: - no changes v3: - updated the commit message - moved the u32 to __le32 conversions to a separate patch v2: - no changes drivers/staging/r8188eu/core/rtw_fw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/r8188eu/core/rtw_fw.c b/drivers/staging/r8188eu/core/rtw_fw.c index 8620f3c92b52..eb4ab11f6b28 100644 --- a/drivers/staging/r8188eu/core/rtw_fw.c +++ b/drivers/staging/r8188eu/core/rtw_fw.c @@ -29,7 +29,7 @@ struct rt_firmware_hdr { * FW for different conditions */ __le16 Version; /* FW Version */ u8 Subversion; /* FW Subversion, default 0x00 */ - u16 Rsvd1; + u8 Rsvd1; /* LONG WORD 1 ---- */ u8 Month; /* Release time Month field */ -- 2.35.1