From: Liang He Date: Wed, 15 Mar 2023 06:20:32 +0000 (+0800) Subject: block: sunvdc: add check for mdesc_grab() returning NULL X-Git-Tag: baikal/mips/sdk5.8.2~138 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=2d3e4656569db64694179b9f96df1f84063d01a8;p=kernel.git block: sunvdc: add check for mdesc_grab() returning NULL [ Upstream commit 6030363199e3a6341afb467ddddbed56640cbf6a ] In vdc_port_probe(), we should check the return value of mdesc_grab() as it may return NULL, which can cause potential NPD bug. Fixes: 136a29bb9255 ("[SPARC64]: Abstract out mdesc accesses for better MD update handling.") Signed-off-by: Liang He Link: https://lore.kernel.org/r/20230315062032.1741692-1-windhl@126.com [axboe: style cleanup] Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- diff --git a/drivers/block/sunvdc.c b/drivers/block/sunvdc.c index 6b2fd630de852..6622dd1aa07b2 100644 --- a/drivers/block/sunvdc.c +++ b/drivers/block/sunvdc.c @@ -983,6 +983,8 @@ static int vdc_port_probe(struct vio_dev *vdev, const struct vio_device_id *id) print_version(); hp = mdesc_grab(); + if (!hp) + return -ENODEV; err = -ENODEV; if ((vdev->dev_no << PARTITION_SHIFT) & ~(u64)MINORMASK) {