[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190530033949.GA8895@zhanggen-UX430UQ>
Date: Thu, 30 May 2019 11:39:49 +0800
From: Gen Zhang <blackgod016574@...il.com>
To: ssantosh@...nel.org
Cc: linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org
Subject: [PATCH] knav_qmss_queue: fix a missing-check bug in
knav_pool_create()
In knav_pool_create(), 'pool->name' is allocated by kstrndup(). It
returns NULL when fails. So 'pool->name' should be checked. And free
'pool' when error.
Signed-off-by: Gen Zhang <blackgod016574@...il.com>
---
diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c
index 8b41837..0f8cb28 100644
--- a/drivers/soc/ti/knav_qmss_queue.c
+++ b/drivers/soc/ti/knav_qmss_queue.c
@@ -814,6 +814,12 @@ void *knav_pool_create(const char *name,
}
pool->name = kstrndup(name, KNAV_NAME_SIZE - 1, GFP_KERNEL);
+ if (!pool->name) {
+ dev_err(kdev->dev, "failed to duplicate for pool(%s)\n",
+ name);
+ ret = -ENOMEM;
+ goto err_name;
+ }
pool->kdev = kdev;
pool->dev = kdev->dev;
@@ -864,6 +870,7 @@ void *knav_pool_create(const char *name,
mutex_unlock(&knav_dev_lock);
err:
kfree(pool->name);
+err_name:
devm_kfree(kdev->dev, pool);
return ERR_PTR(ret);
}
Powered by blists - more mailing lists