summaryrefslogtreecommitdiff
path: root/drivers/hsi
diff options
context:
space:
mode:
authorInsu Yun <wuninsu@gmail.com>2015-10-17 19:25:07 +0000
committerSebastian Reichel <sre@kernel.org>2015-10-19 11:42:02 +0200
commitd2c85ac24ed7636934f469fac8836b87c7e6cb40 (patch)
treed40442df29f9704604f316735ac9f2997d4a05d6 /drivers/hsi
parente74eba049356fdad6713ab66322d9aeb0e85608b (diff)
downloadlinux-exynos-d2c85ac24ed7636934f469fac8836b87c7e6cb40.tar.gz
linux-exynos-d2c85ac24ed7636934f469fac8836b87c7e6cb40.tar.bz2
linux-exynos-d2c85ac24ed7636934f469fac8836b87c7e6cb40.zip
hsi: correctly handle return value of kzalloc
Since kzalloc can be failed in memory pressure, its return value should be checked and handled. Signed-off-by: Insu Yun <wuninsu@gmail.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
Diffstat (limited to 'drivers/hsi')
-rw-r--r--drivers/hsi/hsi.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/hsi/hsi.c b/drivers/hsi/hsi.c
index 35d631e91908..df380d55c58f 100644
--- a/drivers/hsi/hsi.c
+++ b/drivers/hsi/hsi.c
@@ -85,12 +85,14 @@ struct hsi_client *hsi_new_client(struct hsi_port *port,
cl = kzalloc(sizeof(*cl), GFP_KERNEL);
if (!cl)
- return NULL;
+ goto err;
cl->tx_cfg = info->tx_cfg;
if (cl->tx_cfg.channels) {
size = cl->tx_cfg.num_channels * sizeof(*cl->tx_cfg.channels);
cl->tx_cfg.channels = kzalloc(size , GFP_KERNEL);
+ if (!cl->tx_cfg.channels)
+ goto err_tx;
memcpy(cl->tx_cfg.channels, info->tx_cfg.channels, size);
}
@@ -98,6 +100,8 @@ struct hsi_client *hsi_new_client(struct hsi_port *port,
if (cl->rx_cfg.channels) {
size = cl->rx_cfg.num_channels * sizeof(*cl->rx_cfg.channels);
cl->rx_cfg.channels = kzalloc(size , GFP_KERNEL);
+ if (!cl->rx_cfg.channels)
+ goto err_rx;
memcpy(cl->rx_cfg.channels, info->rx_cfg.channels, size);
}
@@ -114,6 +118,12 @@ struct hsi_client *hsi_new_client(struct hsi_port *port,
}
return cl;
+err_rx:
+ kfree(cl->tx_cfg.channels);
+err_tx:
+ kfree(cl);
+err:
+ return NULL;
}
EXPORT_SYMBOL_GPL(hsi_new_client);