diff options
author | Inaky Perez-Gonzalez <inaky@linux.intel.com> | 2009-03-30 20:50:17 -0400 |
---|---|---|
committer | Inaky Perez-Gonzalez <inaky@linux.intel.com> | 2009-05-06 16:48:36 -0400 |
commit | d1a2627a29667fe7c4a9d06e1579a2d65bd39bba (patch) | |
tree | 903881c40ed4d5c6f8c9664bc6f189baedcdef5b /net/wimax | |
parent | 356d6c2d55b71303a17910ea2cce3eba8e44bd29 (diff) |
wimax: fix oops if netlink fails to add attribute
When sending a message to user space using wimax_msg(), if nla_put()
fails, correctly interpret the return code from wimax_msg_alloc() as
an err ptr and return the error code instead of crashing (as it is
assuming than non-NULL means the pointer is ok).
Signed-off-by: Inaky Perez-Gonzalez <inaky@linux.intel.com>
Diffstat (limited to 'net/wimax')
-rw-r--r-- | net/wimax/op-msg.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/net/wimax/op-msg.c b/net/wimax/op-msg.c index 5d149c1b5f0d..9ad4d893a566 100644 --- a/net/wimax/op-msg.c +++ b/net/wimax/op-msg.c | |||
@@ -149,7 +149,8 @@ struct sk_buff *wimax_msg_alloc(struct wimax_dev *wimax_dev, | |||
149 | } | 149 | } |
150 | result = nla_put(skb, WIMAX_GNL_MSG_DATA, size, msg); | 150 | result = nla_put(skb, WIMAX_GNL_MSG_DATA, size, msg); |
151 | if (result < 0) { | 151 | if (result < 0) { |
152 | dev_err(dev, "no memory to add payload in attribute\n"); | 152 | dev_err(dev, "no memory to add payload (msg %p size %zu) in " |
153 | "attribute: %d\n", msg, size, result); | ||
153 | goto error_nla_put; | 154 | goto error_nla_put; |
154 | } | 155 | } |
155 | genlmsg_end(skb, genl_msg); | 156 | genlmsg_end(skb, genl_msg); |
@@ -299,10 +300,10 @@ int wimax_msg(struct wimax_dev *wimax_dev, const char *pipe_name, | |||
299 | struct sk_buff *skb; | 300 | struct sk_buff *skb; |
300 | 301 | ||
301 | skb = wimax_msg_alloc(wimax_dev, pipe_name, buf, size, gfp_flags); | 302 | skb = wimax_msg_alloc(wimax_dev, pipe_name, buf, size, gfp_flags); |
302 | if (skb == NULL) | 303 | if (IS_ERR(skb)) |
303 | goto error_msg_new; | 304 | result = PTR_ERR(skb); |
304 | result = wimax_msg_send(wimax_dev, skb); | 305 | else |
305 | error_msg_new: | 306 | result = wimax_msg_send(wimax_dev, skb); |
306 | return result; | 307 | return result; |
307 | } | 308 | } |
308 | EXPORT_SYMBOL_GPL(wimax_msg); | 309 | EXPORT_SYMBOL_GPL(wimax_msg); |