Skip to contentSkip to conversation

ata: correctly handling failed allocation

PATCH Applied Insu Yun 2 participants 2 messages Dec 29, 2015 – Jan 1, 2016 libata

lore
Share & tools
lore

Insu Yun

author
#0 lore raw

PATCH 1/1 ata: correctly handling failed allocation

Since kzalloc can be failed in memory pressure, return error when failed.

---
 drivers/ata/sata_sx4.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/ata/sata_sx4.c +2 -0
index fab504f..48301cb 100644
@@ -1396,6 +1396,8 @@ static unsigned int pdc20621_dimm_init(struct ata_host *host)
 		addr = 0;
 		length = size * 1024 * 1024;
 		buf = kzalloc(ECC_ERASE_BUF_SZ, GFP_KERNEL);
+		if (!buf)
+			return 1;
 		while (addr < length) {
 			pdc20621_put_to_dimm(host, buf, addr,
 					     ECC_ERASE_BUF_SZ);
Signature · 1 line
1.9.1
Applied
#1 lore raw
Quoted 3 lines · Insu Yun

Since kzalloc can be failed in memory pressure, return error when failed.

Applied to libata/for-4.5.

Thanks.

Signature · 1 line
tejun