Skip to content

Commit 03754ea

Browse files
zhengbin13axboe
authored andcommitted
paride/pcd: need to check if cd->disk is null in pcd_detect
If alloc_disk fails in pcd_init_units, cd->disk & pi are empty, we need to check if cd->disk is null in pcd_detect. Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: zhengbin <zhengbin13@huawei.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent d821cce commit 03754ea

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

  • drivers/block/paride

‎drivers/block/paride/pcd.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -723,9 +723,9 @@ static int pcd_detect(void)
723723
k = 0;
724724
if (pcd_drive_count == 0) { /* nothing spec'd - so autoprobe for 1 */
725725
cd = pcd;
726-
if (pi_init(cd->pi, 1, -1, -1, -1, -1, -1, pcd_buffer,
727-
PI_PCD, verbose, cd->name)) {
728-
if (!pcd_probe(cd, -1, id) && cd->disk) {
726+
if (cd->disk && pi_init(cd->pi, 1, -1, -1, -1, -1, -1,
727+
pcd_buffer, PI_PCD, verbose, cd->name)) {
728+
if (!pcd_probe(cd, -1, id)) {
729729
cd->present = 1;
730730
k++;
731731
} else
@@ -736,11 +736,13 @@ static int pcd_detect(void)
736736
int *conf = *drives[unit];
737737
if (!conf[D_PRT])
738738
continue;
739+
if (!cd->disk)
740+
continue;
739741
if (!pi_init(cd->pi, 0, conf[D_PRT], conf[D_MOD],
740742
conf[D_UNI], conf[D_PRO], conf[D_DLY],
741743
pcd_buffer, PI_PCD, verbose, cd->name))
742744
continue;
743-
if (!pcd_probe(cd, conf[D_SLV], id) && cd->disk) {
745+
if (!pcd_probe(cd, conf[D_SLV], id)) {
744746
cd->present = 1;
745747
k++;
746748
} else

0 commit comments

Comments
 (0)