From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753931AbbL2VTG (ORCPT ); Tue, 29 Dec 2015 16:19:06 -0500 Received: from mail-yk0-f196.google.com ([209.85.160.196]:33819 "EHLO mail-yk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753737AbbL2VSc (ORCPT ); Tue, 29 Dec 2015 16:18:32 -0500 From: Insu Yun To: tj@kernel.org, linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org Cc: taesoo@gatech.edu, yeongjin.jang@gatech.edu, insu@gatech.edu, changwoo@gatech.edu, Insu Yun Subject: [PATCH] ata: correctly handling failed allocation Date: Tue, 29 Dec 2015 16:21:15 -0500 Message-Id: <1451424075-19654-1-git-send-email-wuninsu@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since kzalloc can be failed in memory pressure, return error when failed. Signed-off-by: Insu Yun --- drivers/ata/sata_sx4.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/ata/sata_sx4.c b/drivers/ata/sata_sx4.c index fab504f..48301cb 100644 --- a/drivers/ata/sata_sx4.c +++ b/drivers/ata/sata_sx4.c @@ -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); -- 1.9.1