s390/3270: Fix buffer assignment

JIRA: https://issues.redhat.com/browse/RHEL-86670

commit 5e1a99cf22a65bd91cb43c5380cc14a44b85ad2a
Author: Sven Schnelle <svens@linux.ibm.com>
Date:   Tue Apr 23 07:57:49 2024 +0200

    s390/3270: Fix buffer assignment

    Since commit 1b2ac5a6d61f ("s390/3270: use new address translation
    helpers") rq->buffer is passed unconditionally to virt_to_dma32().
    The 3270 driver allocates requests without buffer, so the value passed
    to virt_to_dma32 might be NULL. Check for NULL before assigning.

    Fixes: 1b2ac5a6d61f ("s390/3270: use new address translation helpers")
    Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
    Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
    Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>

Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
Thomas Huth 2025-04-01 17:58:00 +02:00
parent 1c5d7c1e0b
commit d122482ee6
1 changed files with 4 additions and 2 deletions

View File

@ -148,7 +148,8 @@ struct raw3270_request *raw3270_request_alloc(size_t size)
/*
* Setup ccw.
*/
rq->ccw.cda = virt_to_dma32(rq->buffer);
if (rq->buffer)
rq->ccw.cda = virt_to_dma32(rq->buffer);
rq->ccw.flags = CCW_FLAG_SLI;
return rq;
@ -171,7 +172,8 @@ void raw3270_request_reset(struct raw3270_request *rq)
BUG_ON(!list_empty(&rq->list));
rq->ccw.cmd_code = 0;
rq->ccw.count = 0;
rq->ccw.cda = virt_to_dma32(rq->buffer);
if (rq->buffer)
rq->ccw.cda = virt_to_dma32(rq->buffer);
rq->ccw.flags = CCW_FLAG_SLI;
rq->rescnt = 0;
rq->rc = 0;