Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp41861rdb; Mon, 18 Sep 2023 07:50:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEV8TLiQWxd+SXwKwXnzdnh9AVTFww7AmB69OfseeWfeYJ4OkQYAJgt7iKA2n83dzsKW0DY X-Received: by 2002:a05:6a20:6a20:b0:13a:e955:d958 with SMTP id p32-20020a056a206a2000b0013ae955d958mr9193818pzk.7.1695048600692; Mon, 18 Sep 2023 07:50:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695048600; cv=none; d=google.com; s=arc-20160816; b=wsMp+8wWpolLAZyS+486AHt4FJlYFSXDBWgIM+4RtDsydvY5BdIFHaTwCU+9+MXUT5 9nIBmrHmFzKDkNpU535qft+4RoDEwEOcQPvcV65DI2s8v5XcmgF+/kFunnydUN7E533t gfdt398BvC9HKFMjd3oNEL2AYI1tu7/aeGJocE09aM0Y5NtDVMgJpSzkjhgl1kKYraGO 5E774Gr3T4MAoA/BjKjWR4PMzhkmvmssLkOa1JVg4VFLCI4Abt8FnNNQoauYfuIhxk9+ QNFCOwHudROVcPWRBm3c/trMjES1I3UQ2+iUub3VIUcSG6yt6C9LjPlyIcNP3ur3x2cs mtxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=qhf/uP3BzaKliN1JjTAzysRLJ1VfLUvoN2dZE1cRqW8=; fh=JK/ndWSbgC3wIFtVQRYlwqb52J8S5Iwey1UV/gMmGC0=; b=0OezoxJSStfVqLgd7lbQh4FY6Mwc7Ny9MAhYCxf6MSHO5znKClIljsp+hCulYY2Mdn h/pFFfQHZySTOHHamp3s/ssXf7LA+Iua9P/VIYOhrOdlWNNuzBAH9TfXQ970VkOMmWz+ PAfCzuVNKDzvxMIgBzBAdGsd2vHleFnmoHE6vzBpnOQDyCcGp9s0MIkNQydQBY2lzHzD +h99/E42ISsnlmxaCc+vqLzJBXPMOpaSl8hqCvjm7Txwp5V2s9X+ddH6INjnmAJdDrc8 BwoXZpJmwgSKUjdJYecZrhEslSku1XuHIx6/6mlFzPIyHD+C5DEZ0pnlfNaSS98E2Vt2 YXGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Tijy0zyd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id q137-20020a632a8f000000b0056953da8282si7939729pgq.545.2023.09.18.07.50.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 07:50:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Tijy0zyd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 8BE69809C4C0; Mon, 18 Sep 2023 05:32:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240246AbjIRMbq (ORCPT + 99 others); Mon, 18 Sep 2023 08:31:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241477AbjIRMba (ORCPT ); Mon, 18 Sep 2023 08:31:30 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E752E7 for ; Mon, 18 Sep 2023 05:30:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695040232; 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=qhf/uP3BzaKliN1JjTAzysRLJ1VfLUvoN2dZE1cRqW8=; b=Tijy0zydyy8oLlHtyLnYgAus3Er19UqinZqUR2BXtgYJt4AFGrNbgk0UDh5LVezb80PgeC 4VjydNCZRljs1uQo1fJQpWmN9pdshW8R4EUD4/yTrBcc+sGu2yhp09XgDbjkLvJBFJsZcq IK4tOmEMkUbGXRur8IiVE6431LrdPuo= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-571-t2DXFbl4NO-QRgLTVPLgDg-1; Mon, 18 Sep 2023 08:30:30 -0400 X-MC-Unique: t2DXFbl4NO-QRgLTVPLgDg-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-9a1cf3e6c04so328156166b.3 for ; Mon, 18 Sep 2023 05:30:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695040230; x=1695645030; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qhf/uP3BzaKliN1JjTAzysRLJ1VfLUvoN2dZE1cRqW8=; b=g7mBMA8mqBcSzY5E3NQIYmIKOFIxlbsLknmTpuYJzPVhv6S1o4Y0dXZbImQWA4vJmX vaWq2EEf1soQpaVzGS+b7qMScxOyfj13m557PGT2hXYhb0SQT67raIcgTpWVk9wkCt3w zFds3vc42aeH0AkmFsUd+7ymZRcYryrvvEoBQLPQEIENgIjLdeFpCP0gezygyPLtK593 bDFDu7SCeAytjrollu+MA0K+/VnfgXwbNAZTBFMbiJbAwOfPjLyJtz4XVYOS+yFmGA14 TrOT/2zTzlMhSdFYt6fkK5jMn/72Ocq6sHEybfcXUVa13Ze3/9uy4xg8vTD+viHWDJUG gH/A== X-Gm-Message-State: AOJu0Yx/G9uNwS80QOFxI9RmHrPfvSVO1ZFSFeMvKB8UwhPyvuBIZG1B kXijEoW/V1o6xZDbpr3Un0+biZKaE7lXbgvfMSk0oeVMNF7jvl98VdJnDpcsQKMjltYiNllB15n sCA05uPiiCNhp+Z3cJL8XQ6hJ X-Received: by 2002:a17:906:21a:b0:9ad:e317:33de with SMTP id 26-20020a170906021a00b009ade31733demr6616160ejd.17.1695040229856; Mon, 18 Sep 2023 05:30:29 -0700 (PDT) X-Received: by 2002:a17:906:21a:b0:9ad:e317:33de with SMTP id 26-20020a170906021a00b009ade31733demr6616142ejd.17.1695040229567; Mon, 18 Sep 2023 05:30:29 -0700 (PDT) Received: from [10.40.98.142] ([78.108.130.194]) by smtp.gmail.com with ESMTPSA id se17-20020a170907a39100b009adc86b75d5sm5127516ejc.189.2023.09.18.05.30.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Sep 2023 05:30:28 -0700 (PDT) Message-ID: <77bde3cf-ca94-1cdb-53d8-39df22f8c551@redhat.com> Date: Mon, 18 Sep 2023 14:30:28 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v1 1/2] platform/x86: think-lmi: Replace kstrdup() + strreplace() with kstrdup_and_replace() Content-Language: en-US To: Andy Shevchenko , Mark Pearson , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mark Pearson , Mark Gross References: <20230913092701.440959-1-andriy.shevchenko@linux.intel.com> From: Hans de Goede In-Reply-To: <20230913092701.440959-1-andriy.shevchenko@linux.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 18 Sep 2023 05:32:50 -0700 (PDT) Hi Andy, On 9/13/23 11:27, Andy Shevchenko wrote: > Replace open coded functionalify of kstrdup_and_replace() with a call. > > Signed-off-by: Andy Shevchenko Thank you for the patches, but this one does not apply cleanly. Can you please rebase the series on top of my latest review-hans branch ? Regards, Hans > --- > drivers/platform/x86/think-lmi.c | 43 +++++++++++--------------------- > 1 file changed, 15 insertions(+), 28 deletions(-) > > diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c > index 79346881cadb..94a3c7a74bc4 100644 > --- a/drivers/platform/x86/think-lmi.c > +++ b/drivers/platform/x86/think-lmi.c > @@ -15,7 +15,7 @@ > #include > #include > #include > -#include > +#include > #include > #include > #include > @@ -432,13 +432,11 @@ static ssize_t new_password_store(struct kobject *kobj, > if (!tlmi_priv.can_set_bios_password) > return -EOPNOTSUPP; > > - new_pwd = kstrdup(buf, GFP_KERNEL); > + /* Strip out CR if one is present, setting password won't work if it is present */ > + new_pwd = kstrdup_and_replace(buf, '\n', '\0', GFP_KERNEL); > if (!new_pwd) > return -ENOMEM; > > - /* Strip out CR if one is present, setting password won't work if it is present */ > - strip_cr(new_pwd); > - > /* Use lock in case multiple WMI operations needed */ > mutex_lock(&tlmi_mutex); > > @@ -709,13 +707,11 @@ static ssize_t cert_to_password_store(struct kobject *kobj, > if (!setting->signature || !setting->signature[0]) > return -EACCES; > > - passwd = kstrdup(buf, GFP_KERNEL); > + /* Strip out CR if one is present */ > + passwd = kstrdup_and_replace(buf, '\n', '\0', GFP_KERNEL); > if (!passwd) > return -ENOMEM; > > - /* Strip out CR if one is present */ > - strip_cr(passwd); > - > /* Format: 'Password,Signature' */ > auth_str = kasprintf(GFP_KERNEL, "%s,%s", passwd, setting->signature); > if (!auth_str) { > @@ -765,11 +761,10 @@ static ssize_t certificate_store(struct kobject *kobj, > return ret ?: count; > } > > - new_cert = kstrdup(buf, GFP_KERNEL); > + /* Strip out CR if one is present */ > + new_cert = kstrdup_and_replace(buf, '\n', '\0', GFP_KERNEL); > if (!new_cert) > return -ENOMEM; > - /* Strip out CR if one is present */ > - strip_cr(new_cert); > > if (setting->cert_installed) { > /* Certificate is installed so this is an update */ > @@ -817,13 +812,11 @@ static ssize_t signature_store(struct kobject *kobj, > if (!tlmi_priv.certificate_support) > return -EOPNOTSUPP; > > - new_signature = kstrdup(buf, GFP_KERNEL); > + /* Strip out CR if one is present */ > + new_signature = kstrdup_and_replace(buf, '\n', '\0', GFP_KERNEL); > if (!new_signature) > return -ENOMEM; > > - /* Strip out CR if one is present */ > - strip_cr(new_signature); > - > /* Free any previous signature */ > kfree(setting->signature); > setting->signature = new_signature; > @@ -846,13 +839,11 @@ static ssize_t save_signature_store(struct kobject *kobj, > if (!tlmi_priv.certificate_support) > return -EOPNOTSUPP; > > - new_signature = kstrdup(buf, GFP_KERNEL); > + /* Strip out CR if one is present */ > + new_signature = kstrdup_and_replace(buf, '\n', '\0', GFP_KERNEL); > if (!new_signature) > return -ENOMEM; > > - /* Strip out CR if one is present */ > - strip_cr(new_signature); > - > /* Free any previous signature */ > kfree(setting->save_signature); > setting->save_signature = new_signature; > @@ -985,13 +976,11 @@ static ssize_t current_value_store(struct kobject *kobj, > if (!tlmi_priv.can_set_bios_settings) > return -EOPNOTSUPP; > > - new_setting = kstrdup(buf, GFP_KERNEL); > + /* Strip out CR if one is present */ > + new_setting = kstrdup_and_replace(buf, '\n', '\0', GFP_KERNEL); > if (!new_setting) > return -ENOMEM; > > - /* Strip out CR if one is present */ > - strip_cr(new_setting); > - > /* Use lock in case multiple WMI operations needed */ > mutex_lock(&tlmi_mutex); > > @@ -1163,13 +1152,11 @@ static ssize_t debug_cmd_store(struct kobject *kobj, struct kobj_attribute *attr > if (!tlmi_priv.can_debug_cmd) > return -EOPNOTSUPP; > > - new_setting = kstrdup(buf, GFP_KERNEL); > + /* Strip out CR if one is present */ > + new_setting = kstrdup_and_replace(buf, '\n', '\0', GFP_KERNEL); > if (!new_setting) > return -ENOMEM; > > - /* Strip out CR if one is present */ > - strip_cr(new_setting); > - > if (tlmi_priv.pwd_admin->valid && tlmi_priv.pwd_admin->password[0]) { > auth_str = kasprintf(GFP_KERNEL, "%s,%s,%s;", > tlmi_priv.pwd_admin->password,