Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1236243 > unrolled thread
| Started by | Srinivas Kandagatla <srinivas.kandagatla@linaro.org> |
|---|---|
| First post | 2015-09-30 14:40 +0200 |
| Last post | 2015-10-04 16:50 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 4/4] nvmem: sunxi: Check for memory allocation failure Srinivas Kandagatla <srinivas.kandagatla@linaro.org> - 2015-09-30 14:40 +0200
Re: [PATCH 4/4] nvmem: sunxi: Check for memory allocation failure Greg KH <gregkh@linuxfoundation.org> - 2015-10-04 13:10 +0200
Re: [PATCH 4/4] nvmem: sunxi: Check for memory allocation failure Srinivas Kandagatla <srinivas.kandagatla@linaro.org> - 2015-10-04 16:50 +0200
| From | Srinivas Kandagatla <srinivas.kandagatla@linaro.org> |
|---|---|
| Date | 2015-09-30 14:40 +0200 |
| Subject | [PATCH 4/4] nvmem: sunxi: Check for memory allocation failure |
| Message-ID | <qeoPU-54G-9@gated-at.bofh.it> |
From: Maxime Ripard <maxime.ripard@free-electrons.com>
The sunxi_sid driver doesn't check for kmalloc return status before
derefencing the returned pointer, which could lead to a NULL pointer
dereference if kmalloc failed. Check for its return code to make sure it
deosn't happen.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
drivers/nvmem/sunxi_sid.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/nvmem/sunxi_sid.c b/drivers/nvmem/sunxi_sid.c
index 14777dd..cfa3b85 100644
--- a/drivers/nvmem/sunxi_sid.c
+++ b/drivers/nvmem/sunxi_sid.c
@@ -103,7 +103,7 @@ static int sunxi_sid_probe(struct platform_device *pdev)
struct nvmem_device *nvmem;
struct regmap *regmap;
struct sunxi_sid *sid;
- int i, size;
+ int ret, i, size;
char *randomness;
sid = devm_kzalloc(dev, sizeof(*sid), GFP_KERNEL);
@@ -131,6 +131,11 @@ static int sunxi_sid_probe(struct platform_device *pdev)
return PTR_ERR(nvmem);
randomness = kzalloc(sizeof(u8) * size, GFP_KERNEL);
+ if (!randomness) {
+ ret = -EINVAL;
+ goto err_unreg_nvmem;
+ }
+
for (i = 0; i < size; i++)
randomness[i] = sunxi_sid_read_byte(sid, i);
@@ -140,6 +145,10 @@ static int sunxi_sid_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, nvmem);
return 0;
+
+err_unreg_nvmem:
+ nvmem_unregister(nvmem);
+ return ret;
}
static int sunxi_sid_remove(struct platform_device *pdev)
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Greg KH <gregkh@linuxfoundation.org> |
|---|---|
| Date | 2015-10-04 13:10 +0200 |
| Message-ID | <qfPkZ-6Z8-11@gated-at.bofh.it> |
| In reply to | #1236243 |
On Wed, Sep 30, 2015 at 01:36:31PM +0100, Srinivas Kandagatla wrote: > From: Maxime Ripard <maxime.ripard@free-electrons.com> > > The sunxi_sid driver doesn't check for kmalloc return status before > derefencing the returned pointer, which could lead to a NULL pointer > dereference if kmalloc failed. Check for its return code to make sure it > deosn't happen. > > Reported-by: Dan Carpenter <dan.carpenter@oracle.com> > Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> > --- > drivers/nvmem/sunxi_sid.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) No signed-off-by: from you on this patch? :( -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Srinivas Kandagatla <srinivas.kandagatla@linaro.org> |
|---|---|
| Date | 2015-10-04 16:50 +0200 |
| Message-ID | <qfSLT-3gH-9@gated-at.bofh.it> |
| In reply to | #1239098 |
On 04/10/15 12:04, Greg KH wrote: > On Wed, Sep 30, 2015 at 01:36:31PM +0100, Srinivas Kandagatla wrote: >> From: Maxime Ripard <maxime.ripard@free-electrons.com> >> >> The sunxi_sid driver doesn't check for kmalloc return status before >> derefencing the returned pointer, which could lead to a NULL pointer >> dereference if kmalloc failed. Check for its return code to make sure it >> deosn't happen. >> >> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> >> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> >> --- >> drivers/nvmem/sunxi_sid.c | 11 ++++++++++- >> 1 file changed, 10 insertions(+), 1 deletion(-) > > No signed-off-by: from you on this patch? > Oops!! My bad I missed the sign-off. Thanks for taking this patch, I will make sure I will recheck this before sending. --srini > :( > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web