Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1682909 > unrolled thread
| Started by | "Gustavo A. R. Silva" <garsilva@embeddedor.com> |
|---|---|
| First post | 2017-07-07 07:00 +0200 |
| Last post | 2017-07-10 21: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] iio: multiplexer: add NULL check on devm_kzalloc() and devm_kmemdup() return values "Gustavo A. R. Silva" <garsilva@embeddedor.com> - 2017-07-07 07:00 +0200
Re: [PATCH] iio: multiplexer: add NULL check on devm_kzalloc() and devm_kmemdup() return values Jonathan Cameron <jic23@kernel.org> - 2017-07-09 19:20 +0200
Re: [PATCH] iio: multiplexer: add NULL check on devm_kzalloc() and devm_kmemdup() return values "Gustavo A. R. Silva" <garsilva@embeddedor.com> - 2017-07-10 21:50 +0200
| From | "Gustavo A. R. Silva" <garsilva@embeddedor.com> |
|---|---|
| Date | 2017-07-07 07:00 +0200 |
| Subject | [PATCH] iio: multiplexer: add NULL check on devm_kzalloc() and devm_kmemdup() return values |
| Message-ID | <u0twZ-7l9-3@gated-at.bofh.it> |
Check return values from call to devm_kzalloc() and devm_kmemup()
in order to prevent a NULL pointer dereference.
This issue was detected using Coccinelle and the following semantic patch:
@@
expression x;
identifier fld;
@@
* x = devm_kzalloc(...);
... when != x == NULL
x->fld
Cc: Peter Rosin <peda@axentia.se>
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
Changes in v2:
Add NULL check on devm_kmemup() return value.
drivers/iio/multiplexer/iio-mux.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/iio/multiplexer/iio-mux.c b/drivers/iio/multiplexer/iio-mux.c
index 37ba007..74831fc 100644
--- a/drivers/iio/multiplexer/iio-mux.c
+++ b/drivers/iio/multiplexer/iio-mux.c
@@ -285,6 +285,9 @@ static int mux_configure_channel(struct device *dev, struct mux *mux,
child->ext_info_cache = devm_kzalloc(dev,
sizeof(*child->ext_info_cache) *
num_ext_info, GFP_KERNEL);
+ if (!child->ext_info_cache)
+ return -ENOMEM;
+
for (i = 0; i < num_ext_info; ++i) {
child->ext_info_cache[i].size = -1;
@@ -309,6 +312,9 @@ static int mux_configure_channel(struct device *dev, struct mux *mux,
child->ext_info_cache[i].data = devm_kmemdup(dev, page, ret + 1,
GFP_KERNEL);
+ if (!child->ext_info_cache[i].data)
+ return -ENOMEM;
+
child->ext_info_cache[i].data[ret] = 0;
child->ext_info_cache[i].size = ret;
}
--
2.5.0
[toc] | [next] | [standalone]
| From | Jonathan Cameron <jic23@kernel.org> |
|---|---|
| Date | 2017-07-09 19:20 +0200 |
| Message-ID | <u1o2d-265-1@gated-at.bofh.it> |
| In reply to | #1682909 |
On Fri, 7 Jul 2017 11:26:35 +0200 Peter Rosin <peda@axentia.se> wrote: > On 2017-07-07 06:57, Peter Rosin wrote: > > On 2017-07-07 06:53, Gustavo A. R. Silva wrote: > >> Check return values from call to devm_kzalloc() and devm_kmemup() > > > > If someone cares enough: s/devm_kmemup/evm_kmemdup/ > > Strange, there seems to be some inherent shortage of 'd' characters... > > Cheers, > pea :-) > > > > >> in order to prevent a NULL pointer dereference. > >> > >> This issue was detected using Coccinelle and the following semantic patch: > >> > >> @@ > >> expression x; > >> identifier fld; > >> @@ > >> > >> * x = devm_kzalloc(...); > >> ... when != x == NULL > >> x->fld > >> > >> Cc: Peter Rosin <peda@axentia.se> > >> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com> > > > > Either way, > > > > Reviewed-by: Peter Rosin <peda@axentia.se> > > > > Thanks! > > The relevant patch adding the file in questions hasn't yet worked it's way back to the iio tree so I can't apply this until it does. That is likely to be a few weeks away yet. Please give me a poke if I seem to have forgotten it! Jonathan > > -- > To unsubscribe from this list: send the line "unsubscribe linux-iio" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html
[toc] | [prev] | [next] | [standalone]
| From | "Gustavo A. R. Silva" <garsilva@embeddedor.com> |
|---|---|
| Date | 2017-07-10 21:50 +0200 |
| Message-ID | <u1MQV-L2-11@gated-at.bofh.it> |
| In reply to | #1683768 |
Hi Jonathan, Quoting Jonathan Cameron <jic23@kernel.org>: > On Fri, 7 Jul 2017 11:26:35 +0200 > Peter Rosin <peda@axentia.se> wrote: > >> On 2017-07-07 06:57, Peter Rosin wrote: >> > On 2017-07-07 06:53, Gustavo A. R. Silva wrote: >> >> Check return values from call to devm_kzalloc() and devm_kmemup() >> > >> > If someone cares enough: s/devm_kmemup/evm_kmemdup/ >> >> Strange, there seems to be some inherent shortage of 'd' characters... >> >> Cheers, >> pea :-) >> >> > >> >> in order to prevent a NULL pointer dereference. >> >> >> >> This issue was detected using Coccinelle and the following >> semantic patch: >> >> >> >> @@ >> >> expression x; >> >> identifier fld; >> >> @@ >> >> >> >> * x = devm_kzalloc(...); >> >> ... when != x == NULL >> >> x->fld >> >> >> >> Cc: Peter Rosin <peda@axentia.se> >> >> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com> >> > >> > Either way, >> > >> > Reviewed-by: Peter Rosin <peda@axentia.se> >> > >> > Thanks! >> > > The relevant patch adding the file in questions hasn't yet worked it's > way back to the iio tree so I can't apply this until it does. > > That is likely to be a few weeks away yet. Please give me a poke if > I seem to have forgotten it! > OK, I will do that. :) Thanks! -- Gustavo A. R. Silva
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web