Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3712263imu; Mon, 28 Jan 2019 09:27:50 -0800 (PST) X-Google-Smtp-Source: ALg8bN5GtWjOtV6lKCBsX/kUmDRjP1VxwDeSakj58gClxRQEsxYGwQ3qwihbOSIIChTqHwQfE6m9 X-Received: by 2002:a17:902:a58c:: with SMTP id az12mr16459486plb.299.1548696470811; Mon, 28 Jan 2019 09:27:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548696470; cv=none; d=google.com; s=arc-20160816; b=y4XaY9xbxrh9AQy9UksOcTw+beOUfNk+fIVfEkOKKJTi4iLej5ZzTzEiFBAbMMXUCr Gu/zhNaJPHe3sD09oUgTbqBEiFoGykqcBXagJiK9VeDVVXswk250Z4FHv2RbhkmC2AlZ nTeuUHbfcVwmfy81imQdRzmc7GUmSsKyyWCN5/XKp1Dt4Iwc87JZjt3IRO+0qyaWO9CV 4jOhydiqdTLBW0cZa1DrYNVbYsC7kkXzc+RT0jplC6gJZKqByLzQ7zV7+GD5oH1eWzRB Y1UTeCExQQ8LPsS1hNA+mcU3gZTzYj7PE7F89Z6hkbUcs03A3rXb8q3WrjmE9h2EPkDF emow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0RaE83ZXlJTPPzPfcBpEEanEHggW757xBWo05751nSY=; b=zrHaudr6+O+q+qAP/L04nU/pi9v0MNXAa0PkrrAkrE3W+ucehQjrPYOCLfulHh8liJ UeWq7eN2wtG9FSzeLzLB4gVlQKMy5wvCyH6dEgMjx2n7YAaybyfSKixRP72xHlkHd7sy P+QDACjX0GIKz/JHSp1QJNxrmswnTzOdIvrwVXRspp3yMejod3at1fV4yN0qGxjqvU3t OS7C58Cyacx5FvPuRaj/8Hx/sh+MU+VsE4aF8iGFtvQe49ARY1JD8rpvxKQi+N4aOQsT NBBjVX+KBsg0H+T0/vTOEqhVVN+sfGzjt58TVcE5TuioTfk1LBFaX9YyOCo2CTrDF0/A uwYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YwMxDccY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t10si33702909pgn.551.2019.01.28.09.27.35; Mon, 28 Jan 2019 09:27:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YwMxDccY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731029AbfA1R0X (ORCPT + 99 others); Mon, 28 Jan 2019 12:26:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:46036 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730827AbfA1QAn (ORCPT ); Mon, 28 Jan 2019 11:00:43 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 828F62082E; Mon, 28 Jan 2019 16:00:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691243; bh=U3wxcwT12D3cQwCxKNQzinSeOCVxn1rbgnX4/57JD/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YwMxDccYgG5eCzqbY/h5AouIQiOiGYuYiqLwD5iRhXeyPJr5hc7MPeZ2z2tYZBiVz B7nlodt80dVVkqOG3BfPMoplDlY8XTWb9K5diD5owx1XbxWcYhgdkh7BXZ9Gf0lk6a qFu0rGmD1DhRkoEb4G7DK9G8B+WZPo7QXWthMPuI= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Miroslav Lichvar , Richard Cochran , Jacob Keller , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 030/258] ptp: check gettime64 return code in PTP_SYS_OFFSET ioctl Date: Mon, 28 Jan 2019 10:55:36 -0500 Message-Id: <20190128155924.51521-30-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miroslav Lichvar [ Upstream commit 83d0bdc7390b890905634186baaa294475cd6a06 ] 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 Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- 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 2012551d93e0..796eeffdf93b 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.19.1