summaryrefslogtreecommitdiff
path: root/drivers/s390
diff options
context:
space:
mode:
authorEric Farman <farman@linux.ibm.com>2021-05-11 21:56:29 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-06-03 08:59:13 +0200
commit694f68527e755385b8281548ce742065867b4ad9 (patch)
tree0e3a8ee57342061f0a885795937cec35388d8a4a /drivers/s390
parentd5e4479228b52b324984d68fa45733612dddd2fa (diff)
downloadlinux-694f68527e755385b8281548ce742065867b4ad9.tar.gz
linux-694f68527e755385b8281548ce742065867b4ad9.tar.bz2
linux-694f68527e755385b8281548ce742065867b4ad9.zip
vfio-ccw: Check initialized flag in cp_init()
[ Upstream commit c6c82e0cd8125d30f2f1b29205c7e1a2f1a6785b ] We have a really nice flag in the channel_program struct that indicates if it had been initialized by cp_init(), and use it as a guard in the other cp accessor routines, but not for a duplicate call into cp_init(). The possibility of this occurring is low, because that flow is protected by the private->io_mutex and FSM CP_PROCESSING state. But then why bother checking it in (for example) cp_prefetch() then? Let's just be consistent and check for that in cp_init() too. Fixes: 71189f263f8a3 ("vfio-ccw: make it safe to access channel programs") Signed-off-by: Eric Farman <farman@linux.ibm.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Acked-by: Matthew Rosato <mjrosato@linux.ibm.com> Message-Id: <20210511195631.3995081-2-farman@linux.ibm.com> Signed-off-by: Cornelia Huck <cohuck@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/s390')
-rw-r--r--drivers/s390/cio/vfio_ccw_cp.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/s390/cio/vfio_ccw_cp.c b/drivers/s390/cio/vfio_ccw_cp.c
index 3645d1720c4b..9628e0f3add3 100644
--- a/drivers/s390/cio/vfio_ccw_cp.c
+++ b/drivers/s390/cio/vfio_ccw_cp.c
@@ -636,6 +636,10 @@ int cp_init(struct channel_program *cp, struct device *mdev, union orb *orb)
{
int ret;
+ /* this is an error in the caller */
+ if (cp->initialized)
+ return -EBUSY;
+
/*
* XXX:
* Only support prefetch enable mode now.