From patchwork Wed Sep 13 09:27:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 139162 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:a8d:b0:3f2:4152:657d with SMTP id gr13csp153049vqb; Wed, 13 Sep 2023 16:35:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHOmAgf5WOz9SOzB6wO62GDl8C9KyFln4oTNwxvQ+jdi7edGiHzSWFvihbkyI7V7FDlw6Hs X-Received: by 2002:a05:6358:2910:b0:134:c37f:4b64 with SMTP id y16-20020a056358291000b00134c37f4b64mr4856249rwb.30.1694648108810; Wed, 13 Sep 2023 16:35:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694648108; cv=none; d=google.com; s=arc-20160816; b=aNfq6kdbKWgPjndfN0fA2r8hfoUzWeWtRLyR7ckFCiNkmMBFJXHxvF4MtfPrb0444w kctXskkPOeg55Aln+X2S+eJ2T6uhFo6lohdak7/4N9EAqQUrS7WO680fObwvUmpNp8Mh 4wf6gR1fS6v05nd/otapdsuGcQUNQiOfvub5llPIdz7HjhgSoXC1tD8+1dKnOdhaA175 ST4pwuyEJgZYkuy+X5NjdPgBZqK5ZqJhwD5tolgUtqwQpN4qQB2GAdWjYgilMfi1V/Tp zSeqlkmsgGb9adpftY6GDlDQoX/PR1A9MGpnE3orQUv5qjt0YW0LMWjICsksx7mSgcps t9PQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=xmLCbym+hFmx0VXHXqJoCDtUuUHCGwrHxAPP129WuPQ=; fh=mXCtX0guzfa9IhNQV5qbsRksDFlHtEs5zpKlU3hivCQ=; b=FV4iA0UZ8uqw1b5ZeuteGTR+nhyNuWzUYLBQ8ifVQsO5ng2CQimX+hoyjTe5KQuPCF uaqd0mQkYYIf/knDCnUmo1VUJOizadcIudUPLItbOxcWk5gPDB4n2VOEdSfxH8FpELBK apXv2SFOPXHHFsLSIK5tzKqEyRQ0OKMlUBuO3vYzbUKU9x5bZXhztXEgxRgucjCq3PIC ASG/m+LPlzSY8VjldtncrNvUatK00PhauvMBQsphxSvrxEpiCosCF+snS2yI2poYgN4O tXnVxm31Jxut2s+SgGP40i7bRzp4b//WLpuxIJGA62sq7rT4imkdqBkbP0u9v5VaXF1y EPUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="CWhMvJt/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id a5-20020a655c85000000b0056f7f18bbfdsi173380pgt.632.2023.09.13.16.35.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 16:35:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="CWhMvJt/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id C5986834A9D7; Wed, 13 Sep 2023 02:27:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239318AbjIMJ1M (ORCPT + 36 others); Wed, 13 Sep 2023 05:27:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239259AbjIMJ1L (ORCPT ); Wed, 13 Sep 2023 05:27:11 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8445199E; Wed, 13 Sep 2023 02:27:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694597227; x=1726133227; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=jWur+JX9CJPEdIOhhwD8UkpAw5f715+nAiJqnxYPswY=; b=CWhMvJt/BmdxMJT1BxTe6I5ZLpmsdey+f7kaN8kPU1A1GiHK/vqg/r9w 0jxMGDZGhqWqWahQQS1kVSJsO2f67vz1LGfa1AzHG/1Gq7UY0bK6JS7s/ RmacgYmw7djStn0Y7q94+V5vcO2OFc3iXvswOkznbHsuxlSVKDqvravV7 OFDlstJ8QHjHaWMU3YcXPNrrgZjofr/3eZroCXbvdXh6MnLaINgBVm6ZA ghSQP0BuGgKdzy6aArLSwkr5FJIkMYV6kWf3xmqTGKlNSUJVMYk5pPV14 82z2btdfjMF8zujclpJG+dq83wWnKC/Zg/x1x+UFCUoRLpR4kW5jB4/MR A==; X-IronPort-AV: E=McAfee;i="6600,9927,10831"; a="464979127" X-IronPort-AV: E=Sophos;i="6.02,142,1688454000"; d="scan'208";a="464979127" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2023 02:27:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10831"; a="867717321" X-IronPort-AV: E=Sophos;i="6.02,142,1688454000"; d="scan'208";a="867717321" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga004.jf.intel.com with ESMTP; 13 Sep 2023 02:27:04 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id A3A331E5; Wed, 13 Sep 2023 12:27:03 +0300 (EEST) From: Andy Shevchenko To: Hans de Goede , Mark Pearson , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mark Pearson , Mark Gross , Andy Shevchenko Subject: [PATCH v1 1/2] platform/x86: think-lmi: Replace kstrdup() + strreplace() with kstrdup_and_replace() Date: Wed, 13 Sep 2023 12:27:00 +0300 Message-Id: <20230913092701.440959-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b MIME-Version: 1.0 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 (howler.vger.email [0.0.0.0]); Wed, 13 Sep 2023 02:27:13 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776929056622020801 X-GMAIL-MSGID: 1776967335218986189 Replace open coded functionalify of kstrdup_and_replace() with a call. Signed-off-by: Andy Shevchenko Reviewed-by: Ilpo Järvinen --- 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, From patchwork Wed Sep 13 09:27:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 139471 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp231013vqi; Thu, 14 Sep 2023 02:55:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFPvdbXnOCxjsxK1CUQWUYVJR4GBwzutVA5m0E4hvH/h1NbWEdhMPyBx+I0TEhFeZ/Qowa8 X-Received: by 2002:a05:6870:80ce:b0:1b7:609f:e0d4 with SMTP id r14-20020a05687080ce00b001b7609fe0d4mr5314769oab.15.1694685302817; Thu, 14 Sep 2023 02:55:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694685302; cv=none; d=google.com; s=arc-20160816; b=DLJD26GpihuZm2JIBu2p0BcI6EUMa+2s+WyeTazflDfEWBugsizW5wvD/ws6C+o+le jv0HA7IDsqcIlMyBtjnMX3upQbDUzCQAax5hbd2FQLzxdmkjJSLqKaPigIJ6bGYwCSES 65wnA4ion/5ZxkAJkAAxMNbT6H4jyY6+JqWqm3q7VcBB1ZTbi5dvsKtybG8PlXaU0oTd bRew3YdRGHreD+RKd1cLsjqHS4mCa4L+9Uds8I17GnJGlfBug6p1N4L7tOkaSoSB27gB Z3NZfxHjcCfeoJxtuDwdSjxYbj/0Oj4bXW442W+m6Jj/d+/grJHXEZXVTNz8Rt66uUSt XlFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PI6TRx9vqHNFIXX2GPsfUKGgvfauBadesxjRepLEzzA=; fh=mXCtX0guzfa9IhNQV5qbsRksDFlHtEs5zpKlU3hivCQ=; b=R+tXtmQy8udOcvD+lJpUmUBDxhjj5nZxaG1I8LG3Qdig4dQBqPNODc0rpB5mmZA1Sp DHrvl4nP2g0q2cTi20wnT20YLDnz9T7VJV6WsAgqTGsg/Qj3kBFCxtAjYxqXDnAbYU4Z qdfmzOkMKQcooHjr6Aq6LVHm8QymezUJldMZHviE8jf9QHxtPqQIybJ5AAqKDS94id95 sKo58BGlyN/hzXF/y/xSY2es1/1dMpuLGa8f6Wc1MjPUMUfqcTCJI0om0HMAj2bOMD6L 2g29z7r+0pec3KmBDeGf0Ui+PDo8EMzRe9NBqzYa9qN+V9MG7PYBLimdGID0mMyYMK3N N6bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="av/nzBxy"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id a29-20020a63705d000000b00563a0c1bf06si1149261pgn.428.2023.09.14.02.55.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 02:55:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="av/nzBxy"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 9C56B834A9D9; Wed, 13 Sep 2023 02:27:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239336AbjIMJ1N (ORCPT + 36 others); Wed, 13 Sep 2023 05:27:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239298AbjIMJ1L (ORCPT ); Wed, 13 Sep 2023 05:27:11 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B23A199F; Wed, 13 Sep 2023 02:27:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694597228; x=1726133228; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=j/0F9gh51qv3nxHxA3ApGcaoGCNckyw9Qdr3qP/Jtdc=; b=av/nzBxyKRi7oxx+syn9zzn16+3CjqHB05SRFmVisL0gH1ggwezJ2rll AHDhQFhpMrB5J8WzOvJGigAuLlhkA7hM7Mf7u0HXkLz46LehSI95Axa0Z /UA+7IJwDh6i9eGQ38uin4wgJ1YHyPHYe2nb5u6cjB9lYHeEfC34xkN8x UEuC4gvH2xQE5Miycat+WNPplKr4ZhQQYrcqya1o2V34N39ld4ZkV7iZw DBhPJU2Gm2UsLA8lHQRIKhA0Cp4WoB6ez343/DMp0H16Wx82YKehCkFt3 QB2y27PlMowt2UW4J12IF+7T1ZwfLzrBYzPeS4aHNkm8VgpC96NrsNkFj g==; X-IronPort-AV: E=McAfee;i="6600,9927,10831"; a="464979134" X-IronPort-AV: E=Sophos;i="6.02,142,1688454000"; d="scan'208";a="464979134" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2023 02:27:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10831"; a="867717322" X-IronPort-AV: E=Sophos;i="6.02,142,1688454000"; d="scan'208";a="867717322" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga004.jf.intel.com with ESMTP; 13 Sep 2023 02:27:05 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3EC918C9; Wed, 13 Sep 2023 12:27:04 +0300 (EEST) From: Andy Shevchenko To: Hans de Goede , Mark Pearson , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mark Pearson , Mark Gross , Andy Shevchenko Subject: [PATCH v1 2/2] platform/x86: think-lmi: Use strreplace() to replace a character by nul Date: Wed, 13 Sep 2023 12:27:01 +0300 Message-Id: <20230913092701.440959-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230913092701.440959-1-andriy.shevchenko@linux.intel.com> References: <20230913092701.440959-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 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 (howler.vger.email [0.0.0.0]); Wed, 13 Sep 2023 02:27:15 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776959428671246078 X-GMAIL-MSGID: 1777006335639077568 We can replace p = strchrnul(str, '$OLD'); *p = '\0'; with strreplace(str, '$OLD', '\0'); that does the compatible modification without a need of the temporary variable. Signed-off-by: Andy Shevchenko Reviewed-by: Ilpo Järvinen --- drivers/platform/x86/think-lmi.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c index 94a3c7a74bc4..2f20fafe7f55 100644 --- a/drivers/platform/x86/think-lmi.c +++ b/drivers/platform/x86/think-lmi.c @@ -198,14 +198,6 @@ static struct think_lmi tlmi_priv; static struct class *fw_attr_class; static DEFINE_MUTEX(tlmi_mutex); -/* ------ Utility functions ------------*/ -/* Strip out CR if one is present */ -static void strip_cr(char *str) -{ - char *p = strchrnul(str, '\n'); - *p = '\0'; -} - /* Convert BIOS WMI error string to suitable error code */ static int tlmi_errstr_to_err(const char *errstr) { @@ -411,7 +403,7 @@ static ssize_t current_password_store(struct kobject *kobj, strscpy(setting->password, buf, setting->maxlen); /* Strip out CR if one is present, setting password won't work if it is present */ - strip_cr(setting->password); + strreplace(setting->password, '\n', '\0'); return count; } @@ -921,7 +913,7 @@ static ssize_t display_name_show(struct kobject *kobj, struct kobj_attribute *at static ssize_t current_value_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { struct tlmi_attr_setting *setting = to_tlmi_attr_setting(kobj); - char *item, *value, *p; + char *item, *value; int ret; ret = tlmi_setting(setting->index, &item, LENOVO_BIOS_SETTING_GUID); @@ -934,8 +926,7 @@ static ssize_t current_value_show(struct kobject *kobj, struct kobj_attribute *a ret = -EINVAL; else { /* On Workstations remove the Options part after the value */ - p = strchrnul(value, ';'); - *p = '\0'; + strreplace(value, ';', '\0'); ret = sysfs_emit(buf, "%s\n", value + 1); } kfree(item); @@ -1418,7 +1409,6 @@ static int tlmi_analyze(void) for (i = 0; i < TLMI_SETTINGS_COUNT; ++i) { struct tlmi_attr_setting *setting; char *item = NULL; - char *p; tlmi_priv.setting[i] = NULL; ret = tlmi_setting(i, &item, LENOVO_BIOS_SETTING_GUID); @@ -1435,8 +1425,7 @@ static int tlmi_analyze(void) strreplace(item, '/', '\\'); /* Remove the value part */ - p = strchrnul(item, ','); - *p = '\0'; + strreplace(item, ',', '\0'); /* Create a setting entry */ setting = kzalloc(sizeof(*setting), GFP_KERNEL);