From: Dan Carpenter <hidden> Date: 2017-07-10 07:11:37
The ptp_clock_register() function returns NULL when it's #ifdefed out
because CONFIG_PTP_1588_CLOCK is disabled. Otherwise, it's intended to
return error pointers. Unfortunately, there are a couple paths where we
forget to set the error code. It means that we could result in NULL
pointer dereferences in the callers.
Fixes: d94ba80ebbea ("ptp: Added a brand new class driver for ptp clocks.")
Signed-off-by: Dan Carpenter <redacted>
From: Dan Carpenter <hidden> Date: 2017-07-10 07:16:27
We're checking ptp_clock_register() for NULL but we should be checking
for error pointers.
Fixes: 9c33e4208bce ("cxgb4: Add PTP Hardware Clock (PHC) support")
Signed-off-by: Dan Carpenter <redacted>
From: Richard Cochran <richardcochran@gmail.com> Date: 2017-07-10 09:21:08
On Mon, Jul 10, 2017 at 10:11:37AM +0300, Dan Carpenter wrote:
The ptp_clock_register() function returns NULL when it's #ifdefed out
because CONFIG_PTP_1588_CLOCK is disabled. Otherwise, it's intended to
return error pointers. Unfortunately, there are a couple paths where we
forget to set the error code. It means that we could result in NULL
pointer dereferences in the callers.
Fixes: d94ba80ebbea ("ptp: Added a brand new class driver for ptp clocks.")
This "Fixes" tag references the wrong commit. Please correct it.
Thanks,
Richard
From: Richard Cochran <richardcochran@gmail.com> Date: 2017-07-10 09:35:16
On Mon, Jul 10, 2017 at 10:11:37AM +0300, Dan Carpenter wrote:
The ptp_clock_register() function returns NULL when it's #ifdefed out
because CONFIG_PTP_1588_CLOCK is disabled. Otherwise, it's intended to
return error pointers. Unfortunately, there are a couple paths where we
forget to set the error code. It means that we could result in NULL
pointer dereferences in the callers.
Actually, this description is bogus. Callers will not dereference
NULL, because they are required to check the returned pointer:
/**
* ptp_clock_register() - register a PTP hardware clock driver
*
* @info: Structure describing the new clock.
* @parent: Pointer to the parent device of the new clock.
*
* Returns a valid pointer on success or PTR_ERR on failure. If PHC
* support is missing at the configuration level, this function
* returns NULL, and drivers are expected to gracefully handle that
* case separately.
*/
Thanks,
Richard
From: Dan Carpenter <hidden> Date: 2017-07-10 09:38:30
On Mon, Jul 10, 2017 at 11:21:03AM +0200, Richard Cochran wrote:
On Mon, Jul 10, 2017 at 10:11:37AM +0300, Dan Carpenter wrote:
quoted
The ptp_clock_register() function returns NULL when it's #ifdefed out
because CONFIG_PTP_1588_CLOCK is disabled. Otherwise, it's intended to
return error pointers. Unfortunately, there are a couple paths where we
forget to set the error code. It means that we could result in NULL
pointer dereferences in the callers.
Fixes: d94ba80ebbea ("ptp: Added a brand new class driver for ptp clocks.")
This "Fixes" tag references the wrong commit. Please correct it.
There were two buggy commits so I chose the ealier one. The other buggy
commit is 85a66e550195 ("ptp: create "pins" together with the rest of
attributes"). I should have CC'd Dmitry as well. I can resend.
regards,
dan carpenter
From: Richard Cochran <richardcochran@gmail.com> Date: 2017-07-10 09:48:06
On Mon, Jul 10, 2017 at 12:38:16PM +0300, Dan Carpenter wrote:
There were two buggy commits so I chose the ealier one. The other buggy
No, you are mistaken. In the original patch, NULL or PTR_ERR were
returned on error, and that was not a bug.
If you want to correct the present version of ptp_clock_register() to
always return a valid pointer or PTR_ERR (like the kerneldoc says), be
my guest, but please say that in the change log and reference the
correct commit (namely the one related to disabling POSIX clocks.)
Thanks,
Richard
From: Dan Carpenter <hidden> Date: 2017-07-10 10:29:43
On Mon, Jul 10, 2017 at 11:48:06AM +0200, Richard Cochran wrote:
On Mon, Jul 10, 2017 at 12:38:16PM +0300, Dan Carpenter wrote:
quoted
There were two buggy commits so I chose the ealier one. The other buggy
No, you are mistaken. In the original patch, NULL or PTR_ERR were
returned on error, and that was not a bug.
The "goto no_pps" was a bug you introduced.
But I feel like you're being rude, so I'm not going to resend these
patches. Please fix them yourself.
regards,
dan carpenter