Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp885026pxk; Thu, 17 Sep 2020 20:17:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbidltfztqinuNlh1xCDOVueKzv14DD9d8etpFtFI7aoWn6Mjz7eW+NSvLdGSwYmVfixrc X-Received: by 2002:a17:906:1484:: with SMTP id x4mr33034841ejc.81.1600399078324; Thu, 17 Sep 2020 20:17:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600399078; cv=none; d=google.com; s=arc-20160816; b=OQyqDZO4qSlpOJWOpJA4gtT54gEkoAW3XecEjMtllI8juV3vjjF6ORHzAKcz528f/g okkn9xF2U8Lq+kIAhYdfjjg8RwZ+HcVqLKLcKCTj1GFx/g9if4PJKkOUsyGaINvHXV05 aPdxu7H2OxXs+MEQ2MRIH4XQkwx4t0hT9GwMMXmH31dBsrLXTIL+IXjiYBQEJ6K8+Dg1 p3REatYMw2/wU/78DvoHZz4QVXIzWTmZmpthGiyPHXLO27a/KlWFPciBUINi2NRDoXti qomhT1WQHtrX1xRGeAb+BH5QcL63mcAwHxAVbnY6gSy/ZHzFRrGgt9SHT1F7vQ9hgeTP 7ovA== 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=CWAVxKLwfUnTBQP65QsGQ38WVmiKjuKNiA/3L73v71U=; b=KwNWx5EdS/UL6fuNSJJPTM5WRKtNuKJA1gO/4UMWOdvhexw0Ys4K25O8cl/qMl9SAv TAz92W5i+eIATeriyUXYPCIBFFriD7lPLtzO3CQYJaegauZhFiNDd7FF5Uh/MohX5fys 8dTLJad2npLX6eukHUoyZfz0YRtXotm/7JTbDULS69O74ZtIxSeWpCzDjhp67MS0gifM 0G8lhp7WksNjF7YN3i5o1v1tq6Hvw+OlBjLU9icn6/YfB8k3AcJNOxJuoodt3EO4fI+7 p5x2bFvn81qNnHqJOXT2I4NTrVBSRM+Vp5nzPy8gdUOTVg4zz4nj/h5uRXfbR4AyIARF DaWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KgaP3XbY; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v26si1187949ejr.748.2020.09.17.20.17.34; Thu, 17 Sep 2020 20:17:58 -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=KgaP3XbY; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728949AbgIRDOy (ORCPT + 99 others); Thu, 17 Sep 2020 23:14:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:45976 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726477AbgIRCBo (ORCPT ); Thu, 17 Sep 2020 22:01:44 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7B79C235F8; Fri, 18 Sep 2020 02:01:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394501; bh=5oHdL/SvUebyxDWf8Sl4MMKGthfafe7CIrkoDOYf8F8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KgaP3XbYXb1e4ajAwbwKISlL5T68+ujhDdIByM79eqQq2ROo/G5TFb2quPhlZDXtZ juBl7Gdr+nIWFT2rF0+gSl5uthdkpUcw5j8YNE0KZcCH2ZbivtY4oH2XNZuIa9fxi5 zEqEouzDsIulRhaNygU3Xo7Jqmigk2/KD7tQWvn0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Oleh Kravchenko , Jacek Anaszewski , Pavel Machek , Sasha Levin , linux-leds@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 025/330] leds: mlxreg: Fix possible buffer overflow Date: Thu, 17 Sep 2020 21:56:05 -0400 Message-Id: <20200918020110.2063155-25-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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