From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF1DA22ACDC; Mon, 10 Mar 2025 17:58:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741629531; cv=none; b=kxEbdXObfhQgO/+shz3xv3oKxm35XerTDg7L9wIf77KZ6ZwhSk6tHM7TW4KT25OSF2A/wqUKQFNkvOQY9jIK5w+wW2ca0SZc1nrY/VSHdWh6nwWpThoCX6Llt/o/yUTmUZbDDriDoxmh+qWs2CYuh0nqr+6imsjE2qeyfsUW0IA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741629531; c=relaxed/simple; bh=j2fTbJDmp9WDb31wVADDGh3TUCv1vR02aLP+4qo5yik=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KLemGa4u3q818yNk1HRcYhLugIbtsXIgp5j0c8NMwy5MI9vGtIBUHZwMmPfFNFkRFsnPdJDzYbhJ2Durk+YygR53vwelNEiNLdT8R+yDlhWA5TWNQ4sXwjLf8x8CNYkNdG2UqAv4H52oUBxsHSzXBCmTQPNwF63OGkHojtMvoTo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=AkMevdA5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="AkMevdA5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 476C9C4CEE5; Mon, 10 Mar 2025 17:58:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1741629530; bh=j2fTbJDmp9WDb31wVADDGh3TUCv1vR02aLP+4qo5yik=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AkMevdA5zsixyhfktzx+PNRqxT91lQuE/i/Vb7Cv4+C+Nq4DRLe/WvgGlh/k0aPFq RJhCt1HBS2mTZ0CHk+DytVJZSyDKMSbnHgZrssddDHZ8MuJLQVbyQwKeGpeCFAmJB6 hxZ/OoZoW/9+Oo0y79shegr8RWVdWpI13b400WlM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Richard Cochran , Michal Swiatkowski , Jakub Kicinski Subject: [PATCH 5.15 327/620] ptp: Ensure info->enable callback is always set Date: Mon, 10 Mar 2025 18:02:53 +0100 Message-ID: <20250310170558.515309068@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250310170545.553361750@linuxfoundation.org> References: <20250310170545.553361750@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thomas Weißschuh commit fd53aa40e65f518453115b6f56183b0c201db26b upstream. The ioctl and sysfs handlers unconditionally call the ->enable callback. Not all drivers implement that callback, leading to NULL dereferences. Example of affected drivers: ptp_s390.c, ptp_vclock.c and ptp_mock.c. Instead use a dummy callback if no better was specified by the driver. Fixes: d94ba80ebbea ("ptp: Added a brand new class driver for ptp clocks.") Cc: stable@vger.kernel.org Signed-off-by: Thomas Weißschuh Acked-by: Richard Cochran Reviewed-by: Michal Swiatkowski Link: https://patch.msgid.link/20250123-ptp-enable-v1-1-b015834d3a47@weissschuh.net Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/ptp/ptp_clock.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/drivers/ptp/ptp_clock.c +++ b/drivers/ptp/ptp_clock.c @@ -180,6 +180,11 @@ static void ptp_clock_release(struct dev kfree(ptp); } +static int ptp_enable(struct ptp_clock_info *ptp, struct ptp_clock_request *request, int on) +{ + return -EOPNOTSUPP; +} + static void ptp_aux_kworker(struct kthread_work *work) { struct ptp_clock *ptp = container_of(work, struct ptp_clock, @@ -227,6 +232,9 @@ struct ptp_clock *ptp_clock_register(str mutex_init(&ptp->n_vclocks_mux); init_waitqueue_head(&ptp->tsev_wq); + if (!ptp->info->enable) + ptp->info->enable = ptp_enable; + if (ptp->info->do_aux_work) { kthread_init_delayed_work(&ptp->aux_work, ptp_aux_kworker); ptp->kworker = kthread_create_worker(0, "ptp%d", ptp->index);