瀏覽代碼

sata_sx4: correctly handling failed allocation

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

Signed-off-by: Insu Yun <wuninsu@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Insu Yun 10 年之前
父節點
當前提交
427cc61a44
共有 1 個文件被更改,包括 2 次插入0 次删除
  1. 2 0
      drivers/ata/sata_sx4.c

+ 2 - 0
drivers/ata/sata_sx4.c

@@ -1396,6 +1396,8 @@ static unsigned int pdc20621_dimm_init(struct ata_host *host)
 		addr = 0;
 		addr = 0;
 		length = size * 1024 * 1024;
 		length = size * 1024 * 1024;
 		buf = kzalloc(ECC_ERASE_BUF_SZ, GFP_KERNEL);
 		buf = kzalloc(ECC_ERASE_BUF_SZ, GFP_KERNEL);
+		if (!buf)
+			return 1;
 		while (addr < length) {
 		while (addr < length) {
 			pdc20621_put_to_dimm(host, buf, addr,
 			pdc20621_put_to_dimm(host, buf, addr,
 					     ECC_ERASE_BUF_SZ);
 					     ECC_ERASE_BUF_SZ);