From mboxrd@z Thu Jan 1 00:00:00 1970 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 35D4BBA45 for ; Tue, 7 Mar 2023 18:05:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9EF69C433D2; Tue, 7 Mar 2023 18:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1678212344; bh=Ko8Vc2wcTXVRbVNhsuUQyIMOvOZVz6s0vDZ+OtsHBjI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p1lRaL5iWvA68gPcKLwhaXmFBW7lt/3nEQABes7qSL0I7/wMvdo1/MdE/hI1bAv+z zkHyDqgMc+t7E3Ru9Tmy/9K6H/i+0kvKOG0lNNc8gTl5pILZDUDALBKTNOD+yWrSCd mQcEIE8dYO1/uGOrJkD+KtBcBbPPDEdl7xRbAgMs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Christophe JAILLET , Alexander Gordeev , Heiko Carstens , Sasha Levin Subject: [PATCH 6.1 156/885] s390/vfio-ap: fix an error handling path in vfio_ap_mdev_probe_queue() Date: Tue, 7 Mar 2023 17:51:30 +0100 Message-Id: <20230307170008.691323033@linuxfoundation.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307170001.594919529@linuxfoundation.org> References: <20230307170001.594919529@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Christophe JAILLET [ Upstream commit 08866d34c7099e981918d34aab5d6a437436628f ] The commit in Fixes: has switch the order of a sysfs_create_group() and a kzalloc(). It correctly removed the now useless kfree() but forgot to add a sysfs_remove_group() in case of (unlikely) memory allocation failure. Add it now. Fixes: 260f3ea14138 ("s390/vfio-ap: move probe and remove callbacks to vfio_ap_ops.c") Signed-off-by: Christophe JAILLET Signed-off-by: Alexander Gordeev Link: https://lore.kernel.org/r/d0c0a35eec4fa87cb7f3910d8ac4dc0f7dc9008a.1659283738.git.christophe.jaillet@wanadoo.fr Signed-off-by: Heiko Carstens Signed-off-by: Sasha Levin --- drivers/s390/crypto/vfio_ap_ops.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c index 0b4cc8c597ae6..a109c59f18f78 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -1844,8 +1844,10 @@ int vfio_ap_mdev_probe_queue(struct ap_device *apdev) return ret; q = kzalloc(sizeof(*q), GFP_KERNEL); - if (!q) - return -ENOMEM; + if (!q) { + ret = -ENOMEM; + goto err_remove_group; + } q->apqn = to_ap_queue(&apdev->device)->qid; q->saved_isc = VFIO_AP_ISC_INVALID; @@ -1863,6 +1865,10 @@ int vfio_ap_mdev_probe_queue(struct ap_device *apdev) release_update_locks_for_mdev(matrix_mdev); return 0; + +err_remove_group: + sysfs_remove_group(&apdev->device.kobj, &vfio_queue_attr_group); + return ret; } void vfio_ap_mdev_remove_queue(struct ap_device *apdev) -- 2.39.2