Skip to content

Commit d46c742

Browse files
Li Qionghdeller
authored andcommitted
parisc: ccio-dma: Handle kmalloc failure in ccio_init_resources()
As the possible failure of the kmalloc(), it should be better to fix this error path, check and return '-ENOMEM' error code. Signed-off-by: Li Qiong <[email protected]> Signed-off-by: Helge Deller <[email protected]>
1 parent 4cb2643 commit d46c742

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

drivers/parisc/ccio-dma.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,15 +1380,17 @@ ccio_init_resource(struct resource *res, char *name, void __iomem *ioaddr)
13801380
}
13811381
}
13821382

1383-
static void __init ccio_init_resources(struct ioc *ioc)
1383+
static int __init ccio_init_resources(struct ioc *ioc)
13841384
{
13851385
struct resource *res = ioc->mmio_region;
13861386
char *name = kmalloc(14, GFP_KERNEL);
1387-
1387+
if (unlikely(!name))
1388+
return -ENOMEM;
13881389
snprintf(name, 14, "GSC Bus [%d/]", ioc->hw_path);
13891390

13901391
ccio_init_resource(res, name, &ioc->ioc_regs->io_io_low);
13911392
ccio_init_resource(res + 1, name, &ioc->ioc_regs->io_io_low_hv);
1393+
return 0;
13921394
}
13931395

13941396
static int new_ioc_area(struct resource *res, unsigned long size,
@@ -1543,7 +1545,10 @@ static int __init ccio_probe(struct parisc_device *dev)
15431545
return -ENOMEM;
15441546
}
15451547
ccio_ioc_init(ioc);
1546-
ccio_init_resources(ioc);
1548+
if (ccio_init_resources(ioc)) {
1549+
kfree(ioc);
1550+
return -ENOMEM;
1551+
}
15471552
hppa_dma_ops = &ccio_ops;
15481553

15491554
hba = kzalloc(sizeof(*hba), GFP_KERNEL);

0 commit comments

Comments
 (0)