diff options
author | Wei Yongjun <yongjun_wei@trendmicro.com.cn> | 2013-04-22 22:44:35 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-04-23 13:29:58 -0400 |
commit | 46e407dd349c5ffbb869f5999fa596d1e08f2810 (patch) | |
tree | 3167c1c48ca29d037cb49b02be634a883f7d1854 /drivers/misc/mei | |
parent | 70135393812f4aa10aa891725786a7657064c2fc (diff) |
mei: fix krealloc() misuse in in mei_cl_irq_read_msg()
If krealloc() returns NULL, it doesn't free the original. So any code
of the form 'foo = krealloc(foo, ...);' is almost certainly a bug.
Introduced by commit fcb136e1ac5774909e0d85189f721b8dfa800e0f(mei: fix
reading large reposnes)
Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/mei')
-rw-r--r-- | drivers/misc/mei/interrupt.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c index 5ee2f07c929d..1473cfdbc426 100644 --- a/drivers/misc/mei/interrupt.c +++ b/drivers/misc/mei/interrupt.c | |||
@@ -148,16 +148,16 @@ static int mei_cl_irq_read_msg(struct mei_device *dev, | |||
148 | dev_dbg(&dev->pdev->dev, "message overflow. size %d len %d idx %ld\n", | 148 | dev_dbg(&dev->pdev->dev, "message overflow. size %d len %d idx %ld\n", |
149 | cb->response_buffer.size, | 149 | cb->response_buffer.size, |
150 | mei_hdr->length, cb->buf_idx); | 150 | mei_hdr->length, cb->buf_idx); |
151 | cb->response_buffer.data = | 151 | buffer = krealloc(cb->response_buffer.data, |
152 | krealloc(cb->response_buffer.data, | 152 | mei_hdr->length + cb->buf_idx, |
153 | mei_hdr->length + cb->buf_idx, | 153 | GFP_KERNEL); |
154 | GFP_KERNEL); | ||
155 | 154 | ||
156 | if (!cb->response_buffer.data) { | 155 | if (!buffer) { |
157 | dev_err(&dev->pdev->dev, "allocation failed.\n"); | 156 | dev_err(&dev->pdev->dev, "allocation failed.\n"); |
158 | list_del(&cb->list); | 157 | list_del(&cb->list); |
159 | return -ENOMEM; | 158 | return -ENOMEM; |
160 | } | 159 | } |
160 | cb->response_buffer.data = buffer; | ||
161 | cb->response_buffer.size = | 161 | cb->response_buffer.size = |
162 | mei_hdr->length + cb->buf_idx; | 162 | mei_hdr->length + cb->buf_idx; |
163 | } | 163 | } |