Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1235915 > unrolled thread
| Started by | Olaf Hering <olaf@aepfle.de> |
|---|---|
| First post | 2015-09-30 11:10 +0200 |
| Last post | 2015-09-30 11:30 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] hv: util: catch allocation errors Olaf Hering <olaf@aepfle.de> - 2015-09-30 11:10 +0200
Re: [PATCH] hv: util: catch allocation errors kbuild test robot <lkp@intel.com> - 2015-09-30 11:30 +0200
[PATCH] hv: util: fix memdup_user.cocci warnings kbuild test robot <lkp@intel.com> - 2015-09-30 11:30 +0200
| From | Olaf Hering <olaf@aepfle.de> |
|---|---|
| Date | 2015-09-30 11:10 +0200 |
| Subject | [PATCH] hv: util: catch allocation errors |
| Message-ID | <qelyF-rL-13@gated-at.bofh.it> |
Catch allocation errors in hvt_op_write and hvutil_transport_send.
Fixes: 14b50f80c32d ('Drivers: hv: util: introduce hv_utils_transport abstraction')
Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
drivers/hv/hv_utils_transport.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/hv/hv_utils_transport.c b/drivers/hv/hv_utils_transport.c
index 6a9d80a..13af065 100644
--- a/drivers/hv/hv_utils_transport.c
+++ b/drivers/hv/hv_utils_transport.c
@@ -81,6 +81,8 @@ static ssize_t hvt_op_write(struct file *file, const char __user *buf,
hvt = container_of(file->f_op, struct hvutil_transport, fops);
inmsg = kzalloc(count, GFP_KERNEL);
+ if (!inmsg)
+ return -ENOMEM;
if (copy_from_user(inmsg, buf, count)) {
kfree(inmsg);
return -EFAULT;
@@ -204,9 +206,12 @@ int hvutil_transport_send(struct hvutil_transport *hvt, void *msg, int len)
goto out_unlock;
}
hvt->outmsg = kzalloc(len, GFP_KERNEL);
- memcpy(hvt->outmsg, msg, len);
- hvt->outmsg_len = len;
- wake_up_interruptible(&hvt->outmsg_q);
+ if (hvt->outmsg) {
+ memcpy(hvt->outmsg, msg, len);
+ hvt->outmsg_len = len;
+ wake_up_interruptible(&hvt->outmsg_q);
+ } else
+ ret = -ENOMEM;
out_unlock:
mutex_unlock(&hvt->outmsg_lock);
return ret;
--
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 | kbuild test robot <lkp@intel.com> |
|---|---|
| Date | 2015-09-30 11:30 +0200 |
| Message-ID | <qelS2-Ol-9@gated-at.bofh.it> |
| In reply to | #1235915 |
Hi Olaf, [auto build test results on v4.3-rc3 -- if it's inappropriate base, please ignore] coccinelle warnings: (new ones prefixed by >>) >> drivers/hv/hv_utils_transport.c:83:9-16: WARNING opportunity for memdup_user Please review and possibly fold the followup patch. --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation -- 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 | kbuild test robot <lkp@intel.com> |
|---|---|
| Date | 2015-09-30 11:30 +0200 |
| Subject | [PATCH] hv: util: fix memdup_user.cocci warnings |
| Message-ID | <qelS2-Ol-15@gated-at.bofh.it> |
| In reply to | #1235915 |
drivers/hv/hv_utils_transport.c:83:9-16: WARNING opportunity for memdup_user Use memdup_user rather than duplicating its implementation This is a little bit restricted to reduce false positives Generated by: scripts/coccinelle/api/memdup_user.cocci CC: Olaf Hering <olaf@aepfle.de> Signed-off-by: Fengguang Wu <fengguang.wu@intel.com> --- 0 files changed rule starting on line 17: position variables or mixed modifs interfere with comm_assoc isobool ( ( ( (unknown *to == NULL) >>> IS_ERR(rule starting on line 17:to) | !unknown *to >>> IS_ERR(rule starting on line 17:to) ) | (unknown *NULL == unknown *to) >>> IS_ERR(rule starting on line 17:to) ) || ...) -- 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