Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1609096pxb; Thu, 4 Mar 2021 16:15:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJz8fLG8HHZNvFlZc8WrqFAQ0gcOtfgAcJGWspm69oXvTzP19rLVAZOzVmS+VePRpl4JWVFk X-Received: by 2002:a92:760c:: with SMTP id r12mr6338347ilc.35.1614903301966; Thu, 04 Mar 2021 16:15:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614903301; cv=none; d=google.com; s=arc-20160816; b=p5StS+AwIT/9IcLbqSirHIIjEeTuzyRZjM++r8KfQpKKn/v+e7txAggrCTtxJa4Px0 o69hRh/RsJJFvbg93ifeuX9bHrpez8Pb/a6Dt7IEJ++55N/R2QsLgDJ5knMeZTcGxi0e P98Qe31739AhUcD+jzOG0fo2rG7vPeDcdmEBsWWkXzcb87bK8ous2fWpLcCszm80SWI1 d2n0S0rhyI1DFqliiO3gZ3x4JCulgnL9GlKF/6hCO7PIcAOv1fDqUeMjBGh56tcmEbJi Cvh4z+uD9XQbgicwS/jEkLjIS6h9G5y8f9nzj1pi90NEKCQ65vOMcfbKsuf6GLcju2ha bL+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=vDQP6snMag6XxAEBa+EmQwWRFCxkjx4xBBCVCl5Gh1A=; b=wcgg70T0yBYolze6wwYeOv0WNvq438VMQuzmxsn9ZgAZ9BTaPynA7Hklj4XXDdQXst 6Ux9/Y7V58K7b2E/FYUXj0yTP1i0fj+oFVSF4jeFwlHr5rbh1Wg4aRsaliqogNb/3FXh eChiTUNDPmZswQhlT83VgkhrB+2u4pe/yO4yOjnp4GoZBF/E831qFwKOMVvW/P61FmEb q2pn9bzXw3pGgKL3/R2Ll99MinFaw9OAgk/GqcUGE1+k9GKElYkLqI/yWU0oV+/hoWWc n3s1DF9wr0+StLUlBbpKwCV/zSAMOiWGCMQkiR2i0d95nRtmRhf8lrk7TO3w/ynwVHl3 f4xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YgGaCTVk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g25si710334ioc.83.2021.03.04.16.14.49; Thu, 04 Mar 2021 16:15:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YgGaCTVk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236935AbhCDOFk (ORCPT + 99 others); Thu, 4 Mar 2021 09:05:40 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:25752 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237358AbhCDOFO (ORCPT ); Thu, 4 Mar 2021 09:05:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614866628; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vDQP6snMag6XxAEBa+EmQwWRFCxkjx4xBBCVCl5Gh1A=; b=YgGaCTVkRaVUSz6hA+cPm+arzqiIJ2QJeX8zYvZSC/lgNlpsCJh3ISYGNNoIBQ0T92dWre rUlxrAd16GYDspbpqbf8oU0LYEvpgPPNd/Nd3GY+GsDYXHToH4Q4j5UK1DXFs+706r1xdQ 0bviPl+8gzRkhpzbaburhREBKr4kfqA= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-15-GAEDJeamP0SffiX6NF1NbA-1; Thu, 04 Mar 2021 09:03:47 -0500 X-MC-Unique: GAEDJeamP0SffiX6NF1NbA-1 Received: by mail-ed1-f69.google.com with SMTP id v27so7133067edx.1 for ; Thu, 04 Mar 2021 06:03:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=vDQP6snMag6XxAEBa+EmQwWRFCxkjx4xBBCVCl5Gh1A=; b=BgDf6IX0BHgnKit3jhcXX7j6SOIu6Il36DVoBSU1JPwY6w2CEeClZYoDxfrADaCDsd TbJLOit/k2t8Y9UIBVCJcpNJ8JMwZ431yiKqKhTUaQK0JDq/qNLB1ufwRUVVBSrWYxBB tjnzqaKa+aZImMfc8euIRkuCY1TSNx6+V7BMpfQ2/S4IhEXhguZoZFhkejbXi4FjUzQ0 vAUjAk0HDVCAFWeySPWTFfUrDe9tzoMo4PpwyLA3/Wopv1uWJG9QCzDaiSdiQRnE6WDe ZF4pHloinE+eXAzgNuJ2R7mI3tPUK4IDMbQkl0eoeBi4yrB2ilOF+VtqPyq48LdusAPm lrGQ== X-Gm-Message-State: AOAM530YiF8YF7CEZG2uWHhzw74ADdsveArb8QFOQa5XqiPuzloPGzcW NCyoFmsyJuDM0assHYulOGeLSISYxEirGURlbvxLAPXSaD7wTKvSm2u6H07dnzSPDNNkXhMDh3y rAOtrswjx2F2Qep0L8KJ1klX0 X-Received: by 2002:a17:906:3801:: with SMTP id v1mr4428855ejc.353.1614866624789; Thu, 04 Mar 2021 06:03:44 -0800 (PST) X-Received: by 2002:a17:906:3801:: with SMTP id v1mr4428837ejc.353.1614866624612; Thu, 04 Mar 2021 06:03:44 -0800 (PST) Received: from x1.localdomain (2001-1c00-0c1e-bf00-1054-9d19-e0f0-8214.cable.dynamic.v6.ziggo.nl. [2001:1c00:c1e:bf00:1054:9d19:e0f0:8214]) by smtp.gmail.com with ESMTPSA id jx22sm22114314ejc.105.2021.03.04.06.03.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 04 Mar 2021 06:03:43 -0800 (PST) Subject: Re: [PATCH 1/4] platform/x86: simatic-ipc: add main driver for Siemens devices To: Henning Schild , linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-watchdog@vger.kernel.org Cc: Srikanth Krishnakar , Jan Kiszka , Gerd Haeussler , Guenter Roeck , Wim Van Sebroeck , Mark Gross , Pavel Machek References: <20210302163309.25528-1-henning.schild@siemens.com> <20210302163309.25528-2-henning.schild@siemens.com> From: Hans de Goede Message-ID: Date: Thu, 4 Mar 2021 15:03:43 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: <20210302163309.25528-2-henning.schild@siemens.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 3/2/21 5:33 PM, Henning Schild wrote: > +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 */ >