Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2372898lqp; Sun, 24 Mar 2024 16:23:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXR7mAvjUpBwz9sjVC4/DeLX/+K1bZv2SG9wB0kJxrQZ0Uxww55Yj7xDNnpmA3TlZUZYoFiIfrpuZbvZRPBhdBVDEXK9bjKuwOCs6Ongw== X-Google-Smtp-Source: AGHT+IFu1srEsDU6FQtSDE1NchMG0WmWN05Cu9KT++Lcux77cGkwd0ZCPt5tgJiCE9AHa96846QY X-Received: by 2002:a17:907:7710:b0:a46:bfe2:521f with SMTP id kw16-20020a170907771000b00a46bfe2521fmr4083079ejc.24.1711322610076; Sun, 24 Mar 2024 16:23:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711322610; cv=pass; d=google.com; s=arc-20160816; b=yBmxsrmqNWoE2RDMbvj7DcYE42WM6lM4pTS6zkjP6IwePDUY6FStXG3azvZ1aCM+p+ c2QPNXdcGha70PNfC3OYwvQsqJd+0Kef8b7MMXFsWFm8/BniLsvjdQFEvhUmc+XR0SmN TEuNQR0CI6s9aWR3d9FfN59d9rUYyWpUB5nu7Kq5Srnfc4q69HO/+8wOUPFNV1CmSLUF XsoYmYE2bVxGjAqSn90rXAazg9pFQZRUvTcPS77F8WBXaPZBvii+8PSBsxOVmRRIDbRb vqqNe+ah33L3lVzAGr19cTP1i3rfiCDfdiMqvIfu05uNc5Zamm5EeDzmGgZchReTtKPQ l2Rg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=YgeKJB+dSlRUwkv7+nmzjxwwYQXQbj3aCWJdYnfPr/E=; fh=F+iI4aKHUHiBeiYgTTP6syLnhcB0hX2SWKZbL+8ki18=; b=f6hwD8ZeGZ6DqtoHVcwsOyJKJJ7VszxXS0xT3oYRkID6Pw26jb352Rf4UeUYJWb/Y4 RXVL3AEGmOx0+24asY3xx1pYbuCqZ9tRGzD7xmVnmQEtZGNw7BPNSeG/SVh9sz8M8C/o tdjYFVZDLycZ8cxkk9oqOdtd/UfFY24UBQMMawshYlSnHqVr6RXWTrv0TcPdt/N8pxu9 eWchDfIWwlhiIFcY5/VWWprYTyi8IlHrxoTFJUe2pgb8W0X1JnFUsHmviZSDXx1F1noX mgFSCBHC6VDRE/yWip939m/PndAKgRMke/1aJcduIjyw+4NnByyQW+3tMslDY8Hgr/YS V3CQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qugSufB3; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113061-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113061-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id p27-20020a17090628db00b00a46aebee30esi2095469ejd.455.2024.03.24.16.23.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 16:23:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113061-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qugSufB3; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113061-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113061-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 557D31F24CE3 for ; Sun, 24 Mar 2024 23:14:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7C7331474D6; Sun, 24 Mar 2024 22:37:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qugSufB3" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8AA681474B8; Sun, 24 Mar 2024 22:37:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711319869; cv=none; b=kR0gDChwuedRSfVH/uNfVjCAVwpgITTUVzHizXvI+qClcOgW6a1c13AOgAxbn1RioBzEs1JqpdFqABItkNR9LKUhlCPWTZ61ryV8xLgM4rFucVQyqtIadcqvwA9NffkX9c/nA2Ag3OWJUVpcURu8BWJKU4kWG4FtBajunXhMxxk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711319869; c=relaxed/simple; bh=xZvsKGoR/svHEqZp3qpLgCTKbWwG471nH+E4WozJpus=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rQDV2GeLjuNTiCx+YiqHYuVLqbqTPhUVuDqu2/7MXIvDdisaLaPJampwZPhN4vEtlerxFcTZ3i5U2tb58LZ5QWvU9WHiAiF/tb/y9H4fIui07p37IjCdNMdBtg/jvkpeINGD63bmCuaiADDmkAP0AvaAwqxrJpQHF1/XzH04T/Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qugSufB3; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9843C433A6; Sun, 24 Mar 2024 22:37:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711319869; bh=xZvsKGoR/svHEqZp3qpLgCTKbWwG471nH+E4WozJpus=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qugSufB3lcB5u/n14s843SFK+QmLjZA7eApTyMBm89zio4MySYMCozsmu1PjTj6Uf +8grHeCvpPtTrrF2eNQcrZ/v67fmz48fgFQ5/+n1gj4AA8caWOtQwNqxscOfgtK2E1 9/F0tJSnmpVbYCLyJUBqg3vYVg/OMnhzrOJbcak3ZnhfKsAAE0sl3p/gNsGPi+1reE IxolHAm13vtZ+rwNxnWjHw+zJJ5IHsCvHwqpUQK2oROHyTILLxO7vzzPshMV/7UlCK jCVC8jdrsDsRMFVyHmFpfOs9vWr5pqjgYt4erFJXRLO3pqq1VYn3z4LTK6nf7XRSe6 QYxiZex6r8kbQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Thomas Richter , Sumanth Korikkar , Heiko Carstens , Sasha Levin Subject: [PATCH 6.8 174/715] s390/pai: fix attr_event_free upper limit for pai device drivers Date: Sun, 24 Mar 2024 18:25:53 -0400 Message-ID: <20240324223455.1342824-175-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Thomas Richter [ Upstream commit 225d09d6e5f3870560665a1829d2db79330b4c58 ] When the device drivers are initialized, a sysfs directory is created. This contains many attributes which are allocated with kzalloc(). Should it fail, the memory for the attributes already created is freed in attr_event_free(). Its second parameter is number of attribute elements to delete. This parameter is off by one. When i. e. the 10th attribute fails to get created, attributes numbered 0 to 9 should be deleted. Currently only attributes numbered 0 to 8 are deleted. Fixes: 39d62336f5c1 ("s390/pai: add support for cryptography counters") Reported-by: Sumanth Korikkar Signed-off-by: Thomas Richter Acked-by: Sumanth Korikkar Signed-off-by: Heiko Carstens Signed-off-by: Sasha Levin --- arch/s390/kernel/perf_pai_crypto.c | 2 +- arch/s390/kernel/perf_pai_ext.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/s390/kernel/perf_pai_crypto.c b/arch/s390/kernel/perf_pai_crypto.c index bf8a672b15a41..522a5ea0a9f49 100644 --- a/arch/s390/kernel/perf_pai_crypto.c +++ b/arch/s390/kernel/perf_pai_crypto.c @@ -721,7 +721,7 @@ static int __init attr_event_init(void) for (i = 0; i < ARRAY_SIZE(paicrypt_ctrnames); i++) { ret = attr_event_init_one(attrs, i); if (ret) { - attr_event_free(attrs, i - 1); + attr_event_free(attrs, i); return ret; } } diff --git a/arch/s390/kernel/perf_pai_ext.c b/arch/s390/kernel/perf_pai_ext.c index af7f2b538c8fd..95d1a890640a3 100644 --- a/arch/s390/kernel/perf_pai_ext.c +++ b/arch/s390/kernel/perf_pai_ext.c @@ -611,7 +611,7 @@ static int __init attr_event_init(void) for (i = 0; i < ARRAY_SIZE(paiext_ctrnames); i++) { ret = attr_event_init_one(attrs, i); if (ret) { - attr_event_free(attrs, i - 1); + attr_event_free(attrs, i); return ret; } } -- 2.43.0