netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net-next: Fix minor code bug in timestamping.txt
@ 2017-07-08 19:28 Ahmad Fatoum
  2017-07-11 20:35 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2017-07-08 19:28 UTC (permalink / raw)
  To: David S . Miller; +Cc: Ahmad Fatoum, netdev

Passing (void*)val instead of &val would make a pointer out of an integer
and cause sock_setsockopt to -EFAULT.

See tools/testing/selftests/networking/timestamping/timestamping.c
for a working example.

Cc: David S. Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
 Documentation/networking/timestamping.txt | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/Documentation/networking/timestamping.txt b/Documentation/networking/timestamping.txt
index 196ba17cc344..1be0b6f9e0cb 100644
--- a/Documentation/networking/timestamping.txt
+++ b/Documentation/networking/timestamping.txt
@@ -44,8 +44,7 @@ timeval of SO_TIMESTAMP (ms).
 Supports multiple types of timestamp requests. As a result, this
 socket option takes a bitmap of flags, not a boolean. In
 
-  err = setsockopt(fd, SOL_SOCKET, SO_TIMESTAMPING, (void *) val,
-                   sizeof(val));
+  err = setsockopt(fd, SOL_SOCKET, SO_TIMESTAMPING, &val, sizeof(val));
 
 val is an integer with any of the following bits set. Setting other
 bit returns EINVAL and does not change the current state.
@@ -249,8 +248,7 @@ setsockopt to receive timestamps:
 
   __u32 val = SOF_TIMESTAMPING_SOFTWARE |
 	      SOF_TIMESTAMPING_OPT_ID /* or any other flag */;
-  err = setsockopt(fd, SOL_SOCKET, SO_TIMESTAMPING, (void *) val,
-                   sizeof(val));
+  err = setsockopt(fd, SOL_SOCKET, SO_TIMESTAMPING, &val, sizeof(val));
 
 
 1.4 Bytestream Timestamps
-- 
2.13.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net-next: Fix minor code bug in timestamping.txt
  2017-07-08 19:28 [PATCH] net-next: Fix minor code bug in timestamping.txt Ahmad Fatoum
@ 2017-07-11 20:35 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-07-11 20:35 UTC (permalink / raw)
  To: ahmad; +Cc: netdev

From: Ahmad Fatoum <ahmad@a3f.at>
Date: Sat,  8 Jul 2017 21:28:44 +0200

> Passing (void*)val instead of &val would make a pointer out of an integer
> and cause sock_setsockopt to -EFAULT.
> 
> See tools/testing/selftests/networking/timestamping/timestamping.c
> for a working example.
> 
> Cc: David S. Miller <davem@davemloft.net>
> Cc: netdev@vger.kernel.org
> Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>

Applied.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-07-11 20:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-08 19:28 [PATCH] net-next: Fix minor code bug in timestamping.txt Ahmad Fatoum
2017-07-11 20:35 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).