Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3624604pxv; Mon, 5 Jul 2021 01:43:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4AuEa/0DCE09Km+Pp8YsKX8LxTVpgkZJmWDxaeAh9DAG67lDKehrPlURHL1mc2+ue6MP6 X-Received: by 2002:a02:90d0:: with SMTP id c16mr438872jag.106.1625474592200; Mon, 05 Jul 2021 01:43:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625474592; cv=none; d=google.com; s=arc-20160816; b=g6Z0RKvECF5T0n7VhmwtuS8ZO28bMsz03TeTfKNhMnj5xqnbbKjo/18jPlFgpv4rg6 a2XRF/KIjk5xIv3OsD79t7s8WdRnvY4qgGMtOkO4F56JRo9L+mJ006AeT1eptfwrjOu9 iMSbOCNo/flqwnUWDtFriLWEPwZ4CvQ6kJfnxtDtYSomH6jEJlwkQHgYiCnifyXpVztu YAq+YgDK5L4woXTs6c4+IIEHnG5wF2pr4y4SiibNSefFHBPf/TuV0iZHIUqKMGpHt2mP MM7Mbc8RYfyqK6F6oERFM8NMilYXGv4wuHMbkl3r/hSfNQ7fLISLhL86olb05qfzhThQ R+aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=udDTBtrk/gdF+iIE8xhOMvCm1JiKmmAGCZCHZVavCXc=; b=TFfKPdOwNmCjZaMG6ULVX1IO8DYL9JNravrqkqPQs+aMlZ7IOWYSlw98lp3S86mjP5 NDNHewc5KYf69NMd9E2xynn+x4S4nKAOhplrNXs+83fq52J2qZ3NYpItwpUIFufzkII3 8vc1Wgu8ud9etAAuBbEWDIkw88+y9hi/JWpQn44yd/K7VStc6TijV3J4NVuMtG2/Lws4 W5nGIQkWeWyCuLylcr47bOSDhq0TyNT9UXmHx05ODou6XeCdsS4ldby24/OgF+CvDBXj tdZcOSlyHHG5SROk1eBATQx5WAFVFm24h4ltOgqMDgYvk37M4al4z81xv/Lt14Imiy3V MPsQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si15555746jav.18.2021.07.05.01.43.00; Mon, 05 Jul 2021 01:43:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230181AbhGEIpJ (ORCPT + 99 others); Mon, 5 Jul 2021 04:45:09 -0400 Received: from inva021.nxp.com ([92.121.34.21]:47996 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230107AbhGEIpI (ORCPT ); Mon, 5 Jul 2021 04:45:08 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 013D420261C; Mon, 5 Jul 2021 10:42:31 +0200 (CEST) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id BE98020067D; Mon, 5 Jul 2021 10:42:30 +0200 (CEST) Received: from localhost.localdomain (mega.ap.freescale.net [10.192.208.232]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id 2F0ED183ACDF; Mon, 5 Jul 2021 16:42:29 +0800 (+08) From: Yangbo Lu To: netdev@vger.kernel.org Cc: Yangbo Lu , linux-kernel@vger.kernel.org, Richard Cochran , "David S . Miller" , Rui Sousa , Sebastien Laveze Subject: [net] ptp: fix NULL pointer dereference in ptp_clock_register Date: Mon, 5 Jul 2021 16:53:06 +0800 Message-Id: <20210705085306.15470-1-yangbo.lu@nxp.com> X-Mailer: git-send-email 2.17.1 X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix NULL pointer dereference in ptp_clock_register. The argument "parent" of ptp_clock_register may be NULL pointer. Fixes: 73f37068d540 ("ptp: support ptp physical/virtual clocks conversion") Reported-by: kernel test robot Signed-off-by: Yangbo Lu --- drivers/ptp/ptp_clock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c index f012fa581cf4..ce6d9fc85607 100644 --- a/drivers/ptp/ptp_clock.c +++ b/drivers/ptp/ptp_clock.c @@ -236,7 +236,7 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info, } /* PTP virtual clock is being registered under physical clock */ - if (parent->class && parent->class->name && + if (parent && parent->class && parent->class->name && strcmp(parent->class->name, "ptp") == 0) ptp->is_virtual_clock = true; base-commit: 6ff63a150b5556012589ae59efac1b5eeb7d32c3 -- 2.25.1