s390/dasd: fix error checks in dasd_copy_pair_store()
dasd_add_busid() can return an error via ERR_PTR() if an allocation
fails. However, two callsites in dasd_copy_pair_store() do not check
the result, potentially resulting in a NULL pointer dereference. Fix
this by checking the result with IS_ERR() and returning the error up
the stack.
Fixes: a91ff09d39
("s390/dasd: add copy pair setup")
Signed-off-by: Carlos López <clopez@suse.de>
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Link: https://lore.kernel.org/r/20240715112434.2111291-3-sth@linux.ibm.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
1f5a333153
commit
8e64d2356c
@ -2248,13 +2248,19 @@ static ssize_t dasd_copy_pair_store(struct device *dev,
|
|||||||
|
|
||||||
/* allocate primary devmap if needed */
|
/* allocate primary devmap if needed */
|
||||||
prim_devmap = dasd_find_busid(prim_busid);
|
prim_devmap = dasd_find_busid(prim_busid);
|
||||||
if (IS_ERR(prim_devmap))
|
if (IS_ERR(prim_devmap)) {
|
||||||
prim_devmap = dasd_add_busid(prim_busid, DASD_FEATURE_DEFAULT);
|
prim_devmap = dasd_add_busid(prim_busid, DASD_FEATURE_DEFAULT);
|
||||||
|
if (IS_ERR(prim_devmap))
|
||||||
|
return PTR_ERR(prim_devmap);
|
||||||
|
}
|
||||||
|
|
||||||
/* allocate secondary devmap if needed */
|
/* allocate secondary devmap if needed */
|
||||||
sec_devmap = dasd_find_busid(sec_busid);
|
sec_devmap = dasd_find_busid(sec_busid);
|
||||||
if (IS_ERR(sec_devmap))
|
if (IS_ERR(sec_devmap)) {
|
||||||
sec_devmap = dasd_add_busid(sec_busid, DASD_FEATURE_DEFAULT);
|
sec_devmap = dasd_add_busid(sec_busid, DASD_FEATURE_DEFAULT);
|
||||||
|
if (IS_ERR(sec_devmap))
|
||||||
|
return PTR_ERR(sec_devmap);
|
||||||
|
}
|
||||||
|
|
||||||
/* setting copy relation is only allowed for offline secondary */
|
/* setting copy relation is only allowed for offline secondary */
|
||||||
if (sec_devmap->device)
|
if (sec_devmap->device)
|
||||||
|
Loading…
Reference in New Issue
Block a user