aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/ipv6_sockglue.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv6/ipv6_sockglue.c')
-rw-r--r--net/ipv6/ipv6_sockglue.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 286c86735aed..f5f9582a8d39 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -413,7 +413,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
413 } 413 }
414 414
415 /* routing header option needs extra check */ 415 /* routing header option needs extra check */
416 if (optname == IPV6_RTHDR && opt->srcrt) { 416 if (optname == IPV6_RTHDR && opt && opt->srcrt) {
417 struct ipv6_rt_hdr *rthdr = opt->srcrt; 417 struct ipv6_rt_hdr *rthdr = opt->srcrt;
418 switch (rthdr->type) { 418 switch (rthdr->type) {
419 case IPV6_SRCRT_TYPE_0: 419 case IPV6_SRCRT_TYPE_0:
@@ -795,12 +795,16 @@ int compat_ipv6_setsockopt(struct sock *sk, int level, int optname,
795EXPORT_SYMBOL(compat_ipv6_setsockopt); 795EXPORT_SYMBOL(compat_ipv6_setsockopt);
796#endif 796#endif
797 797
798static int ipv6_getsockopt_sticky(struct sock *sk, struct ipv6_opt_hdr *hdr, 798static int ipv6_getsockopt_sticky(struct sock *sk, struct ipv6_txoptions *opt,
799 char __user *optval, int len) 799 char __user *optval, int len)
800{ 800{
801 if (!hdr) 801 struct ipv6_opt_hdr *hdr;
802
803 if (!opt || !opt->hopopt)
802 return 0; 804 return 0;
803 len = min_t(int, len, ipv6_optlen(hdr)); 805 hdr = opt->hopopt;
806
807 len = min_t(unsigned int, len, ipv6_optlen(hdr));
804 if (copy_to_user(optval, hdr, ipv6_optlen(hdr))) 808 if (copy_to_user(optval, hdr, ipv6_optlen(hdr)))
805 return -EFAULT; 809 return -EFAULT;
806 return len; 810 return len;
@@ -940,7 +944,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
940 { 944 {
941 945
942 lock_sock(sk); 946 lock_sock(sk);
943 len = ipv6_getsockopt_sticky(sk, np->opt->hopopt, 947 len = ipv6_getsockopt_sticky(sk, np->opt,
944 optval, len); 948 optval, len);
945 release_sock(sk); 949 release_sock(sk);
946 return put_user(len, optlen); 950 return put_user(len, optlen);