From mboxrd@z Thu Jan 1 00:00:00 1970 From: Miroslav Lichvar Subject: [PATCH net-next 2/8] ptp: check gettime64 return code in PTP_SYS_OFFSET ioctl Date: Fri, 9 Nov 2018 11:14:43 +0100 Message-ID: <20181109101449.15398-3-mlichvar@redhat.com> References: <20181109101449.15398-1-mlichvar@redhat.com> Cc: Richard Cochran , Jacob Keller , Miroslav Lichvar To: netdev@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:36812 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727532AbeKITys (ORCPT ); Fri, 9 Nov 2018 14:54:48 -0500 In-Reply-To: <20181109101449.15398-1-mlichvar@redhat.com> Sender: netdev-owner@vger.kernel.org List-ID: If a gettime64 call fails, return the error and avoid copying data back to user. Cc: Richard Cochran Cc: Jacob Keller Signed-off-by: Miroslav Lichvar --- drivers/ptp/ptp_chardev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c index b54b8158ff8a..3c681bed5703 100644 --- a/drivers/ptp/ptp_chardev.c +++ b/drivers/ptp/ptp_chardev.c @@ -228,7 +228,9 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg) pct->sec = ts.tv_sec; pct->nsec = ts.tv_nsec; pct++; - ptp->info->gettime64(ptp->info, &ts); + err = ptp->info->gettime64(ptp->info, &ts); + if (err) + goto out; pct->sec = ts.tv_sec; pct->nsec = ts.tv_nsec; pct++; @@ -281,6 +283,7 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg) break; } +out: kfree(sysoff); return err; } -- 2.17.2