Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp722816rdf; Fri, 3 Nov 2023 13:03:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH5P37cjqJ2VSUiHZB9IijH8ujJj+7rg466UhipvHHrtkp9lyFXO0I8t0o+0N11NvGi+z6E X-Received: by 2002:a05:6358:881f:b0:168:ed99:4e74 with SMTP id hv31-20020a056358881f00b00168ed994e74mr33990620rwb.20.1699041826962; Fri, 03 Nov 2023 13:03:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699041826; cv=none; d=google.com; s=arc-20160816; b=W0X0/2Yzkif9CIizJ4eEsZCrv30Bf5f0VFoVE56bajJUlT9fNgGqp6IE5nV36AHCDs vHNiW8JKUh66hh9lUBxzEauhdL9o60WVLQ9dJYLbS0gXReJPqCj/Kf+y2en3FS3NWzx0 u+quOYBsTufO1IUXnEC4DG8pp+uUGqi1PlxV/2Py61icsgN9Ai/g86Ex6DnGGBKGCWAf zgjXCy+QMfDZN34AVlQIq+QHKdFJdJ47sTGzBbXbopDjMMZ1EqEQbcUCsAh9yh9HCK7+ 9t7nRQ0acPUiRyb8rEG8ogiLEyyIyOjh9hZHmpM/uUP2LxtSxGICFvPu4GCO2vnF9yAF I8ww== 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=qIFVGXdCLffn9mcTJTwcAJyWj7qYuhrQ17QQu5kprxs=; fh=SvhOHfehUV8tt+/DHSWfRHpXzQQzyN3k16tgFjiVtw0=; b=P7FNh3vnKjSz779UM8Krj/P0jqqz3XxTca5s7/7L5HzRKktFl1Gs87RmY5TphsIGay W7MeiRTISOBg7jONDzhvKPa1cAyfnSTbnNSPiacKBFckWMzFTII+Pp1l3/zeu2Y4Dtb+ cMjxBHcVAIh3GLknWWTWhgAJ/4zz9zBhNIlqxQcnmezjAC1FcnwG8UTWDfJWYT3tBfqP T86KVS4yU5DQJXLEnW0KpyjRF1cvkPGrEFM32uYr+SKs/nNFCpFmMvU2gtu3Z5JJxmOx Zw1TZSXDjkCLcdIsmXKOr1fBpPghT75e2KrO4dW25Gqo+cAX//HqLnGfShpnm1Q2aMag Ul6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="UNnN/AiP"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id bs192-20020a6328c9000000b005b82f5f99cfsi1987631pgb.603.2023.11.03.13.03.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:03:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="UNnN/AiP"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id F40D283DB95B; Fri, 3 Nov 2023 13:03:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378015AbjKCUDk (ORCPT + 99 others); Fri, 3 Nov 2023 16:03:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229527AbjKCUDg (ORCPT ); Fri, 3 Nov 2023 16:03:36 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8448DD53; Fri, 3 Nov 2023 13:03:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699041813; x=1730577813; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Nsq+DlizAAeSWWNzWMj45TaDhpGuvaTz6ItsP0chKHM=; b=UNnN/AiPim/QbC6K9V3TJSTv/fHdm3MgCDdkEQmgxzoBoDgES3ZGEAKz qPM3qgJxCR3OYErmgVuvZQNnzwZQuvtdp69stzuyMOJ2Ni2BfQcbhBiIW rq3Vs7zDixiHxZDTdSo4bwajL8jHl7SjcANnEKWXRRhtn1IzIG+XJjNw3 AndQPAbH1G143BI7KvZuDHHul7h9FnNkHGbvcPYhYHAGBwqWuigIJbOlM HulBxIzA6YKUiEqVaZ1GsBllI5ZXYch+gJ0X/gVCOw5kuc0abQyl7heHp 4SKM1jjb+7o/pCt2eN2wsINNi9rOoBTDS92Df4wx4pYPLfarmZHlVx688 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10883"; a="1894389" X-IronPort-AV: E=Sophos;i="6.03,275,1694761200"; d="scan'208";a="1894389" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2023 13:03:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10883"; a="832126756" X-IronPort-AV: E=Sophos;i="6.03,275,1694761200"; d="scan'208";a="832126756" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga004.fm.intel.com with ESMTP; 03 Nov 2023 13:03:27 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id C26B82A6; Fri, 3 Nov 2023 21:53:13 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Linus Walleij , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Pavel Machek , Lee Jones Subject: [PATCH v1 2/4] leds: trigger: gpio: Convert to use kstrtox() Date: Fri, 3 Nov 2023 21:53:08 +0200 Message-Id: <20231103195310.948327-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231103195310.948327-1-andriy.shevchenko@linux.intel.com> References: <20231103195310.948327-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE, 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 03 Nov 2023 13:03:43 -0700 (PDT) sscanf() is a heavy one and moreover requires additional boundary checks. Convert driver to use kstrtou8() in gpio_trig_inverted_store(). Signed-off-by: Andy Shevchenko --- drivers/leds/trigger/ledtrig-gpio.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/leds/trigger/ledtrig-gpio.c b/drivers/leds/trigger/ledtrig-gpio.c index d91ae7fde3cf..8a30f9228186 100644 --- a/drivers/leds/trigger/ledtrig-gpio.c +++ b/drivers/leds/trigger/ledtrig-gpio.c @@ -53,14 +53,12 @@ static ssize_t gpio_trig_brightness_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t n) { struct gpio_trig_data *gpio_data = led_trigger_get_drvdata(dev); - unsigned desired_brightness; + u8 desired_brightness; int ret; - ret = sscanf(buf, "%u", &desired_brightness); - if (ret < 1 || desired_brightness > 255) { - dev_err(dev, "invalid value\n"); - return -EINVAL; - } + ret = kstrtou8(buf, 10, &desired_brightness); + if (ret) + return ret; gpio_data->desired_brightness = desired_brightness; -- 2.40.0.1.gaa8946217a0b