Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3744745pxk; Tue, 29 Sep 2020 05:20:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzN36noOmT2Oj6b8tdVq3KZZUFs/tAZSzSv3X+bw0oyn5Y2tsBjtuwgpgnuckgkgXXOCZsq X-Received: by 2002:a17:906:4c89:: with SMTP id q9mr3704825eju.290.1601382030786; Tue, 29 Sep 2020 05:20:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601382030; cv=none; d=google.com; s=arc-20160816; b=m2LJprK5BpgLUUEln3TCA9uxaZ6WY0nFpC5BwWUS/F8LpF3WTxTg4PQv227yCMPh9Z RTPWi87iZN1OiNrT92vEFiQBOO2Ivf7gEhs4wQR5cPuYJzbOWfNk/mx3GUCHKyFq/WmS aYq4TrEfIE+yq6L9R/9o/EHXC1nOInyHvwp1rhQvqPUTadiL2C7ZWP2fmasRueBH2GJD Y86GOaziwJN+xUteblyb43aO8Hbiy2VyEqGYZuqxgnkPQuM1LJw0bqTcf1Z5yHU1PAaG UFUNi8U1sNsekg4AK8lbPjrZl2lfvQIyDISLydaRb8mqC01H5ejWVE38gVE7Ol+sZKxo lMYQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CWAVxKLwfUnTBQP65QsGQ38WVmiKjuKNiA/3L73v71U=; b=I8qyRo6HahNeKBpydjqdxfszzYUPWQ94jXiAswHAEZE+DfKzageQJs4vt3DyKiDZQj wsI0Hk+k1SCdUcnrDkXIpofI8RDb33CkV2LMyMOwMPJbK+DmTsgJK7ZI5bYLf00Al3mH 4RnH777XuTAs6TwGux8HWogyoBqXEPAzet3szht4sixNDs1wr6sVAwxFj/akdM7hKtJV B5vk6td1x4KW3I5odglVygnq2dWv3whVnsMXpBEKuj1kfLniiVmYVPcktKBZSGAXM0hM z9Xj3ULtySJDp4U+QutMTEVZzcd/2jvBxmky7ExvBEaNqIfubpeuc2+U/lQb/kiMu8KH AY6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DP4FL8uU; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f19si2568387ejx.348.2020.09.29.05.20.07; Tue, 29 Sep 2020 05:20:30 -0700 (PDT) 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=@kernel.org header.s=default header.b=DP4FL8uU; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732309AbgI2MRI (ORCPT + 99 others); Tue, 29 Sep 2020 08:17:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:54450 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730044AbgI2LhA (ORCPT ); Tue, 29 Sep 2020 07:37:00 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BA16C23EB3; Tue, 29 Sep 2020 11:32:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601379162; bh=5oHdL/SvUebyxDWf8Sl4MMKGthfafe7CIrkoDOYf8F8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DP4FL8uU66d/6sNm20bJMdKvZI9Msev1ib3wvmwyIaSWnbBSq3mmb+tcFYRYozGGw vGGprY2zxk6oiwvdI4b0s5JkhKW3AJI9Ny3SeWmyMWG/qdiy/6Gg1SJ1Zv5CBtcf4x xhhQ05qQ+CkvL4Dck2xvn3vBQf3vFcsIrVLmNJGo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jacek Anaszewski , Pavel Machek , Oleh Kravchenko , Sasha Levin Subject: [PATCH 5.4 023/388] leds: mlxreg: Fix possible buffer overflow Date: Tue, 29 Sep 2020 12:55:54 +0200 Message-Id: <20200929110011.606750822@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929110010.467764689@linuxfoundation.org> References: <20200929110010.467764689@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Oleh Kravchenko [ Upstream commit 7c6082b903ac28dc3f383fba57c6f9e7e2594178 ] Error was detected by PVS-Studio: V512 A call of the 'sprintf' function will lead to overflow of the buffer 'led_data->led_cdev_name'. Acked-by: Jacek Anaszewski Acked-by: Pavel Machek Signed-off-by: Oleh Kravchenko Signed-off-by: Pavel Machek Signed-off-by: Sasha Levin --- drivers/leds/leds-mlxreg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/leds/leds-mlxreg.c b/drivers/leds/leds-mlxreg.c index cabe379071a7c..82aea1cd0c125 100644 --- a/drivers/leds/leds-mlxreg.c +++ b/drivers/leds/leds-mlxreg.c @@ -228,8 +228,8 @@ static int mlxreg_led_config(struct mlxreg_led_priv_data *priv) brightness = LED_OFF; led_data->base_color = MLXREG_LED_GREEN_SOLID; } - sprintf(led_data->led_cdev_name, "%s:%s", "mlxreg", - data->label); + snprintf(led_data->led_cdev_name, sizeof(led_data->led_cdev_name), + "mlxreg:%s", data->label); led_cdev->name = led_data->led_cdev_name; led_cdev->brightness = brightness; led_cdev->max_brightness = LED_ON; -- 2.25.1