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 DC5AA26B081; Thu, 13 Feb 2025 14:53:29 +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=1739458410; cv=none; b=oeXgJpdj/DwGXIo7CrCj+M6nYltdwEYTz6PMR5NcFFu5jOri/A+mjXNS47firiexgd8g0zFC1LIqfafRh98ZKQKiH2Q3lzn42dsiWfz1ll9cTzsdjMSrlX059dXIlbgA2l4XbOApLGvsGE8/8gnN6H+YNbhL5Buh5puKRPvFLGQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739458410; c=relaxed/simple; bh=e4D3z8v9KjDfyBhkyPzhckmqNf5z6m4b+wHnJbFUmzs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kIMN3m+dxC6NJZb1Dn4xVPcbtLXU8D/gQxigdauDnh03Y3mxP4jLn1I1VwDcscZOBGVeJFilTn58MlpJszM+PANBsIH/mnMsG8jKc1/ejClKmp9qXQXNWM9lOIuNj4JQZGLRQHem8KNidB/oomcN9ac/txAXsiYdBu1uPWL97OQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=XZqWaDCg; 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="XZqWaDCg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C09FC4CED1; Thu, 13 Feb 2025 14:53:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1739458409; bh=e4D3z8v9KjDfyBhkyPzhckmqNf5z6m4b+wHnJbFUmzs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XZqWaDCgz7OP17fOWqbcdrKcJiKWQ7aGvn0LWYRUnJYJ/c4GpFSY+4ntUILD+BZX7 7mLCEQGnf8OMZ7IC6p7eiZvmcl5XgsY4/3uihiBBpYaoGRIPrETpmbChc/LdgyX92M y4udQflNuB8ApePr11jEXtk3M4IWs4B+lc4toL1U= 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 6.12 391/422] ptp: Ensure info->enable callback is always set Date: Thu, 13 Feb 2025 15:29:00 +0100 Message-ID: <20250213142451.637121533@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250213142436.408121546@linuxfoundation.org> References: <20250213142436.408121546@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.12-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 @@ -217,6 +217,11 @@ static int ptp_getcycles64(struct ptp_cl return info->gettime64(info, ts); } +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, @@ -294,6 +299,9 @@ struct ptp_clock *ptp_clock_register(str ptp->info->getcrosscycles = ptp->info->getcrosststamp; } + 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);