Initializing automatic __free variables to NULL without need (e.g. branches with different allocations), followed by actual allocation is in contrary to explicit coding rules guiding cleanup.h: "Given that the "__free(...) = NULL" pattern for variables defined at the top of the function poses this potential interdependency problem the recommendation is to always define and assign variables in one statement and not group variable definitions at the top of the function when __free() is used." Code does not have a bug, but is less readable and uses discouraged coding practice, so fix that by moving declaration to the place of assignment. Signed-off-by: Krzysztof Kozlowski --- drivers/ptp/ptp_chardev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c index c61cf9edac48..2a52cc7bccd1 100644 --- a/drivers/ptp/ptp_chardev.c +++ b/drivers/ptp/ptp_chardev.c @@ -350,13 +350,13 @@ typedef int (*ptp_gettimex_fn)(struct ptp_clock_info *, static long ptp_sys_offset_extended(struct ptp_clock *ptp, void __user *arg, ptp_gettimex_fn gettimex_fn) { - struct ptp_sys_offset_extended *extoff __free(kfree) = NULL; struct ptp_system_timestamp sts; if (!gettimex_fn) return -EOPNOTSUPP; - extoff = memdup_user(arg, sizeof(*extoff)); + struct ptp_sys_offset_extended *extoff __free(kfree) = + memdup_user(arg, sizeof(*extoff)); if (IS_ERR(extoff)) return PTR_ERR(extoff); @@ -402,11 +402,11 @@ static long ptp_sys_offset_extended(struct ptp_clock *ptp, void __user *arg, static long ptp_sys_offset(struct ptp_clock *ptp, void __user *arg) { - struct ptp_sys_offset *sysoff __free(kfree) = NULL; struct ptp_clock_time *pct; struct timespec64 ts; - sysoff = memdup_user(arg, sizeof(*sysoff)); + struct ptp_sys_offset *sysoff __free(kfree) = + memdup_user(arg, sizeof(*sysoff)); if (IS_ERR(sysoff)) return PTR_ERR(sysoff); -- 2.51.0