[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ed715381-016a-5bf7-3cdb-d340747c4498@redhat.com>
Date: Thu, 4 Mar 2021 15:03:43 +0100
From: Hans de Goede <hdegoede@...hat.com>
To: Henning Schild <henning.schild@...mens.com>,
linux-kernel@...r.kernel.org, linux-leds@...r.kernel.org,
platform-driver-x86@...r.kernel.org, linux-watchdog@...r.kernel.org
Cc: Srikanth Krishnakar <skrishnakar@...il.com>,
Jan Kiszka <jan.kiszka@...mens.com>,
Gerd Haeussler <gerd.haeussler.ext@...mens.com>,
Guenter Roeck <linux@...ck-us.net>,
Wim Van Sebroeck <wim@...ux-watchdog.org>,
Mark Gross <mgross@...ux.intel.com>,
Pavel Machek <pavel@....cz>
Subject: Re: [PATCH 1/4] platform/x86: simatic-ipc: add main driver for
Siemens devices
Hi,
On 3/2/21 5:33 PM, Henning Schild wrote:
<snip>
> +static inline u32 simatic_ipc_get_station_id(u8 *data)
> +{
> + u32 station_id = SIMATIC_IPC_INVALID_STATION_ID;
> + int i;
> + struct {
> + u8 type; /* type (0xff = binary) */
> + u8 len; /* len of data entry */
> + u8 reserved[3];
> + u32 station_id; /* station id (LE) */
> + } __packed * data_entry = (void *)data;
> +
> + /* find 4th entry in OEM data */
> + for (i = 0; i < 3; i++)
> + data_entry = (void *)((u8 *)(data_entry) + data_entry->len);
> +
> + /* decode station id */
> + if (data_entry && data_entry->type == 0xff && data_entry->len == 9)
> + station_id = le32_to_cpu(data_entry->station_id);
> +
> + return station_id;
> +}
> +
> +static inline void
> +simatic_ipc_find_dmi_entry_helper(const struct dmi_header *dh, void *_data)
> +{
> + u32 *id = _data;
> +
> + if (dh->type != DMI_ENTRY_OEM)
> + return;
> +
> + *id = simatic_ipc_get_station_id((u8 *)dh + sizeof(struct dmi_header));
> +}
Please take dh->length into account here and make sure that you don't walk
past the end of the DMI tables during the parsing here.
Regards,
Hans
> +
> +#endif /* __PLATFORM_DATA_X86_SIMATIC_IPC_H */
>
Powered by blists - more mailing lists