Skip to content

Commit 9ceb524

Browse files
00xcgregkh
authored andcommitted
s390/dasd: fix error checks in dasd_copy_pair_store()
[ Upstream commit 8e64d23 ] 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]> Signed-off-by: Sasha Levin <[email protected]>
1 parent d6f4121 commit 9ceb524

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
@@ -2258,13 +2258,19 @@ static ssize_t dasd_copy_pair_store(struct device *dev,
22582258

22592259
/* allocate primary devmap if needed */
22602260
prim_devmap = dasd_find_busid(prim_busid);
2261-
if (IS_ERR(prim_devmap))
2261+
if (IS_ERR(prim_devmap)) {
22622262
prim_devmap = dasd_add_busid(prim_busid, DASD_FEATURE_DEFAULT);
2263+
if (IS_ERR(prim_devmap))
2264+
return PTR_ERR(prim_devmap);
2265+
}
22632266

22642267
/* allocate secondary devmap if needed */
22652268
sec_devmap = dasd_find_busid(sec_busid);
2266-
if (IS_ERR(sec_devmap))
2269+
if (IS_ERR(sec_devmap)) {
22672270
sec_devmap = dasd_add_busid(sec_busid, DASD_FEATURE_DEFAULT);
2271+
if (IS_ERR(sec_devmap))
2272+
return PTR_ERR(sec_devmap);
2273+
}
22682274

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

0 commit comments

Comments
 (0)