Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 8e64d23

Browse files
00xcaxboe
authored andcommitted
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: a91ff09 ("s390/dasd: add copy pair setup") Signed-off-by: Carlos López <[email protected]> Signed-off-by: Stefan Haberland <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 1f5a333 commit 8e64d23

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/s390/block/dasd_devmap.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2248,13 +2248,19 @@ static ssize_t dasd_copy_pair_store(struct device *dev,
22482248

22492249
/* allocate primary devmap if needed */
22502250
prim_devmap = dasd_find_busid(prim_busid);
2251-
if (IS_ERR(prim_devmap))
2251+
if (IS_ERR(prim_devmap)) {
22522252
prim_devmap = dasd_add_busid(prim_busid, DASD_FEATURE_DEFAULT);
2253+
if (IS_ERR(prim_devmap))
2254+
return PTR_ERR(prim_devmap);
2255+
}
22532256

22542257
/* allocate secondary devmap if needed */
22552258
sec_devmap = dasd_find_busid(sec_busid);
2256-
if (IS_ERR(sec_devmap))
2259+
if (IS_ERR(sec_devmap)) {
22572260
sec_devmap = dasd_add_busid(sec_busid, DASD_FEATURE_DEFAULT);
2261+
if (IS_ERR(sec_devmap))
2262+
return PTR_ERR(sec_devmap);
2263+
}
22582264

22592265
/* setting copy relation is only allowed for offline secondary */
22602266
if (sec_devmap->device)

0 commit comments

Comments
 (0)