Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2576339lqp; Mon, 25 Mar 2024 03:15:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXI9uAnrVYfepCyyZ5uuktx4LBjimchWHZleEPhUot35Lu8gZcecAFC5O7ts7W5PUic7Y+aDuZeeKX0+OkOuA7jaQLmvkw/AmacVrOQNw== X-Google-Smtp-Source: AGHT+IFAIkTfkpWOXo8o0++x66egNoMqTGPzOrMfDyclXhzn/+fY8VsyAOroaCuG8MbhvKfmnq4V X-Received: by 2002:a05:6a20:5483:b0:1a3:c604:8486 with SMTP id i3-20020a056a20548300b001a3c6048486mr2625341pzk.34.1711361705177; Mon, 25 Mar 2024 03:15:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711361705; cv=pass; d=google.com; s=arc-20160816; b=cypXHDxjmUpZHNDmJwqi+T3CdUJzvqQl8bNgawlp6EGh855FIELw0OR+gNh+JqwPqc UebitJg3oKmvFdn2hQ3uF5kWOh+U86QXg83/o220xoZ/6RpRNMbpXfz5ommfNTsfXNFz Qy2cb3iWurnL2Wpw/Xvjhb8H5ugiRqzBcBIAoDzPhFdBL7UGaoof4VsBO3lv217CkCXZ ajgAVRAwC4b7t0hxpob6Lj8CQYkvoXalGHmWm39Bq9aQT18IOPI5Cw2O+s0Bxx3/VF0M yzMvgh/ZLdEWoAYkC2e+dca+P++jWTkFGWMmJwDFF9CUJy8nIj5bUGmNr4tUHtOpszrF sd3g== 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=qcs3ygh8n/NvwRh0EJ2wuy/GgTAe8jfZ4KDiPNJxRHk=; fh=F+iI4aKHUHiBeiYgTTP6syLnhcB0hX2SWKZbL+8ki18=; b=fiDnJjyK9wKHAKkTjtNi56SXuct27j6rRjtYhIxIiY8OwhvazXQc2gOsXnrlo1lgDA 2H2osEp1xuJl/b6gUkFNhHwqAxC8wd4EfYbT31tosHSJfibzklKKcnehVekd4AzNnc1i w9c6GJoaaATG5/7pqXlOQWtZcXRLgW4WIRg3saHnxSvbVzeGi/J6j0E48yItEGKCi0b1 e9Niza5Oo+WYt9bA1dIRIY6uxwPe0yTsvdCHEOTLrXScW1W2g+I3gCtNLIAn5no6tEUY SZMupS+opSY8Vri7jcoSMmCeVMg5Y7nLYhs4SUj0mQv7xVyAbVELMm4u3HSJUr5ef8Ac mGeg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=etgnbJhM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115867-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115867-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id g8-20020a17090a4b0800b0029f7c2e0619si10871420pjh.177.2024.03.25.03.15.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 03:15:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-115867-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=etgnbJhM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115867-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115867-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 07B45B3CA1A for ; Mon, 25 Mar 2024 09:37:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0A8A0159204; Mon, 25 Mar 2024 03:02:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="etgnbJhM" 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 916B7146008; Sun, 24 Mar 2024 23:14:23 +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=1711322063; cv=none; b=pMjbzYuv8fm2gVdoj4VERUIu7MEQazLJpj5Yoa+6y0Q12puof01kEHS2RCtD1thizEJQ4qOxMk9zjESwb+5PvhsUwFYW74/N1R6liRH2Zlnju5CZcTuMtQJ1SFt/m310SYRHHMYDA+kBltMGOh0UPmOE3HgJT7I3/3hmdYS+KaI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711322063; c=relaxed/simple; bh=4wew/RSvJCKd70KkUzTO7tnMZFfdWo4VyC7/kEuXCSw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n5JHFSNJSvmJ29AEaGsBUjsvWKS3rKiFKP4Ro02KZ47UJFVqFkxtG+f+t0FUV5BYEFSYd3v3jNkPpVWX4AXgfFIRZ1xF09jeacnKoZG1qquKpcMJxjX0HPALZh6iEhHCaQ4/KONXM/AT/cNtdpA76j3Tx7PYPvU5chZJpxBTFpA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=etgnbJhM; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD01EC433C7; Sun, 24 Mar 2024 23:14:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711322063; bh=4wew/RSvJCKd70KkUzTO7tnMZFfdWo4VyC7/kEuXCSw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=etgnbJhMKkw5rdGEaiSQrVbJVZlwx6Qjg2u2DQyP0F8TWYCV870+1JEZVnn7no5lY BhAky3tcpUmClUpAVOBfdrmGzObMEZxpwXgqpBXvQIpz1GGckhm3MkHYj3L5kJLLmE Mpr9qGePHQB3z5B4XjdhknxXkdtBSGixaBFU0DiViFPwOMIE7lFGXsET9R9bO/Gn5n Ui0HMN90H8LnSlYt7VGnjhd3lSTtGVY0+OYla4Sq7p/PRx0m7rMxD6Waxj995bfrsW W01FwjvpRyrV3YGTE7ba9DfUDFoUznmwduNisbkIosRdF9fE+U/EXzAlznuMeSD8RP IiUcPiMtD+lKw== 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.1 136/451] s390/pai: fix attr_event_free upper limit for pai device drivers Date: Sun, 24 Mar 2024 19:06:52 -0400 Message-ID: <20240324231207.1351418-137-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324231207.1351418-1-sashal@kernel.org> References: <20240324231207.1351418-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 6826e2a69a216..f61a652046cfb 100644 --- a/arch/s390/kernel/perf_pai_crypto.c +++ b/arch/s390/kernel/perf_pai_crypto.c @@ -647,7 +647,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 74b53c531e0cd..b4d89654183a2 100644 --- a/arch/s390/kernel/perf_pai_ext.c +++ b/arch/s390/kernel/perf_pai_ext.c @@ -612,7 +612,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