Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2344311rwr; Fri, 28 Apr 2023 09:07:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Gkau90ZZENQd6afPlhlhRTvQaPcRORlIEE4rrKuwiMS7VU4p4dnkrcvQanE8AVVXFUMzx X-Received: by 2002:a05:6a20:6a05:b0:ef:cd5b:a5c7 with SMTP id p5-20020a056a206a0500b000efcd5ba5c7mr7194167pzk.56.1682698041036; Fri, 28 Apr 2023 09:07:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682698041; cv=none; d=google.com; s=arc-20160816; b=vXmBch5EKN9RL8kSvWpFgHyyotFx3Aq7QkF2Z/oyQAfhUkK5kTww6M9p9tADJ9u/Ne 3/Y00ABlJxkoDo6ggHkDWAG79dkwi98mkTK8wDllTnXv3AODMeRcwMgs5h5Soy+sJszA jXYYd8al3T+1Nle12UBWgduDOzVhKSws2urtcWPnDbbgPZmEpCH149iMZgrLmFiqTz4l ro7RCfFK8DgurEaSTErx74lslNvb0NJMZhTjxYcBqxk2MD6tIF3oIKmwpkMZrXC7KlTt JY185DFnqbT4NjPGPTatjXjEwulO8YBDayM08k7MSQUi34bJIuF+w00inhM2McM96ft3 FHbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=bmentXLBnPrijbzoUd8PXp8q+4FpfP0A1Bl0IfvWSFA=; b=M57XYTxtZ+vefXPtHOQwqFgAHlmf/hdoZBH3X1fyCIMexMm7eIF1IefTEItj8muqYr oSttfKEFoXPIM1C7DEaoh+TBE3jy1CvRoOoFv4Fh3qQLnVa72UfTS9A6LFjsmzFMEVBh cQSHWJ2hZRgJ9fLqLx1Xm55ORRAgmTsyoB4GwHprze5soBMxQTidwBYbEyD7B11uxGGz JHz5ztkgzeVdh76+ZkDmzYP9ZODo4OS/ECVt2UGxKTqMJbHnSFVt+NGIIBerC4cmK6UP rTxqMMrHzxKItvC3WfxsRXxZxJ6m2E/xT+myS0Z94kgN7QNduhQsm8krZPReZV7dh3fJ rZSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="TOBtH/q9"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i24-20020a63e458000000b00502e7159b0fsi22315533pgk.175.2023.04.28.09.07.03; Fri, 28 Apr 2023 09:07:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="TOBtH/q9"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344556AbjD1QEc (ORCPT + 99 others); Fri, 28 Apr 2023 12:04:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229768AbjD1QEa (ORCPT ); Fri, 28 Apr 2023 12:04:30 -0400 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3160F49D9; Fri, 28 Apr 2023 09:04:24 -0700 (PDT) Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2a8bdcf87f4so95338141fa.2; Fri, 28 Apr 2023 09:04:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682697862; x=1685289862; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=bmentXLBnPrijbzoUd8PXp8q+4FpfP0A1Bl0IfvWSFA=; b=TOBtH/q9f8eWOs+RSq9goQS6RHh5QgK6XU70wOHAw3bP9JxtEzncfpcZvCjahfncxp iIR0ldf3LqlQve5JfwSV0Ly7BqD8aDrdczrAgsEFTpbZBD9Eoky+BBAgmzFf/ifPx2fe C6q1Y8giiHdZURC7XM9vU5v7DUg7BB7BAsWlIftTZXis6tPoqSILv+P7KgcPX8qu8f4Q D1Sps2qleDqMQ8c7Qb+dhkZFn0zIDN7v4WCjL889XZvN8JMhD8V7kiQ7G012cOPO/5oL zrSaDO9SrYk5uzICyDh8vVMLwo9n+cQ5Fd4pe8orml37eqHPQi769Y+3v3wpGLSNV0WI yo1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682697862; x=1685289862; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bmentXLBnPrijbzoUd8PXp8q+4FpfP0A1Bl0IfvWSFA=; b=XRJ86uotzLu7DS1LtoZ0+RNXtHm5nXe9pZUnd/+9QcRjXN7LLcZaY9/55BxBeIkHrR KGxL/KTfm+9oh5C1QyROGfSfTmIalt1ccSiUzgE86vx+x3nNrhPvvdmmtStb66U5nSb8 QqCRg/+7sSBUL/wZSZYXbcgR0/COuNoVAzu7BPqQO5Wjr2DzrFRcdQcSjb4TsrUj/QDn VNDEiAPzUHzzM0m+qXzUycsh2/gg9o1hvLaEiBZVA42jEQTvtbftegMLnNlXOAfptKEC GDkHUjzQChlz/S3rcJMX7WS49Ndjnm5cukyl+g3JnDaWALHtiSzCDK2mTWRFiyti9gS4 fldA== X-Gm-Message-State: AC+VfDwXvJb5KgTL0HENkc2i80V6xBHXSiIbCG5HhLxFYrs65WH7Oa9c 6Bej6Ev5R3yBrVBbhBOmaoi57eiKG0FI5EFdQaQ= X-Received: by 2002:a2e:9bcc:0:b0:2ab:2af7:4053 with SMTP id w12-20020a2e9bcc000000b002ab2af74053mr1616635ljj.24.1682697862197; Fri, 28 Apr 2023 09:04:22 -0700 (PDT) MIME-Version: 1.0 References: <20230420165454.9517-1-jorge.lopez2@hp.com> <20230420165454.9517-9-jorge.lopez2@hp.com> <462b5d12-0430-4fbe-8c26-7b6126556ec8@t-8ch.de> In-Reply-To: <462b5d12-0430-4fbe-8c26-7b6126556ec8@t-8ch.de> From: Jorge Lopez Date: Fri, 28 Apr 2023 11:03:56 -0500 Message-ID: Subject: Re: [PATCH v11 08/14] HP BIOSCFG driver - bioscfg-h To: =?UTF-8?Q?Thomas_Wei=C3=9Fschuh?= Cc: hdegoede@redhat.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 28, 2023 at 10:36=E2=80=AFAM Thomas Wei=C3=9Fschuh wrote: > > On 2023-04-28 10:24:40-0500, Jorge Lopez wrote: > > On Sun, Apr 23, 2023 at 7:01=E2=80=AFAM Thomas Wei=C3=9Fschuh wrote: > > > > > > On 2023-04-20 11:54:48-0500, Jorge Lopez wrote: > > > > --- > > > > drivers/platform/x86/hp/hp-bioscfg/bioscfg.h | 613 +++++++++++++++= ++++ > > > > 1 file changed, 613 insertions(+) > > > > create mode 100644 drivers/platform/x86/hp/hp-bioscfg/bioscfg.h > > > > > > > +/* global structure used by multiple WMI interfaces */ > > > > +extern struct bioscfg_priv bioscfg_drv; > > > > + > > > > +enum hp_wmi_data_type { > > > > + HPWMI_STRING_TYPE =3D 0x00, > > > > + HPWMI_INTEGER_TYPE =3D 0x01, > > > > + HPWMI_ENUMERATION_TYPE =3D 0x02, > > > > + HPWMI_ORDERED_LIST_TYPE =3D 0x03, > > > > + HPWMI_PASSWORD_TYPE =3D 0x04, > > > > + HPWMI_SECURE_PLATFORM_TYPE =3D 0x05, > > > > + HPWMI_SURE_START_TYPE =3D 0x06 > > > > +}; > > > > > > Unused. > > > > Both hp_wmi_data_type and hp_wmi_data_elements are used > > for instance HP_WMI_STRING_TYPE > > > > bioscfg.c:338: case HPWMI_STRING_TYPE: > > bioscfg.c:626: case HPWMI_STRING_TYPE: > > bioscfg.c:722: case HPWMI_STRING_TYPE: > > bioscfg.c:798: case HPWMI_STRING_TYPE: > > bioscfg.c:906: ret =3D hp_init_bios_attributes(HPWMI_STRING_TYPE, > > HP_WMI_BIOS_STRING_GUID); > > bioscfg.h:247: HPWMI_STRING_TYPE > > Indeed. I think I just searched for "hp_wmi_data_type". > > The proper enum hp_wmi_data_type type should be used instead of > "int attr_type". > Done! > > > > > > + > > > > +enum hp_wmi_elements_count { > > > > + STRING_ELEM_CNT =3D 12, > > > > + INTEGER_ELEM_CNT =3D 13, > > > > + ENUM_ELEM_CNT =3D 13, > > > > + ORDERED_ELEM_CNT =3D 12, > > > > + PASSWORD_ELEM_CNT =3D 15 > > > > +}; > > > > > > To make it clearer where these values come from you could put them in= to > > > the enum hp_wmi_data_elements. > > > > > > ... > > > ORD_LIST_ELEMENTS =3D 11, > > > ORD_LIST_ELEM_CNT =3D 12, > > > ... > > > > Done! changes provided across all files affected. > > > > > > > > But replacing the loop logic would remove the need for these enums > > > completely. > > > > > > > _CNT values are necessary when elements are read from a buffer ( > > populate_string_elements_from_buffer). > > _CNT values are not needed when elements are read from a package > > (populate_string_package_data) > > Hm, I don't see why populate_string_elements_from_buffer() would need > the _CNT define. > > (In another review mail I wrote down how I would expect it to look > without the loop) > > > > > > > + > > > > +#define ATTRIBUTE_PROPERTY_STORE(curr_val, type) = \ > > > > + static ssize_t curr_val##_store(struct kobject *kobj, = \ > > > > + struct kobj_attribute *attr, = \ > > > > + const char *buf, size_t count= ) \ > > > > + { = \ > > > > + char *p =3D NULL; = \ > > > > + char *attr_value =3D NULL; = \ > > > > + int i; = \ > > > > + int ret =3D -EIO; = \ > > > > + = \ > > > > + attr_value =3D kstrdup(buf, GFP_KERNEL); = \ > > > > + if (!attr_value) = \ > > > > + return -ENOMEM; = \ > > > > + = \ > > > > + p =3D memchr(attr_value, '\n', count); = \ > > > > + if (p !=3D NULL) = \ > > > > + *p =3D '\0'; = \ > > > > > > This can also truncate the string if there is data after the newline. > > > > This is a expected behavior as described by Hans in a later email > > I'm fine with stripping a trailing newline. > > But this truncates the string at the first newline. > > "foo\nbar" -> "foo" > "\nfoo" -> "" > All inputs expected by this driver and respectively by BIOS are a single line. For this reason, '\n' will cause the string to be truncated. I propose reporting a warning message indicating that the data entered has a '\n' character and will be truncated in addition to failing the operation with -EINVAL >