Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752335AbdLLRMl (ORCPT ); Tue, 12 Dec 2017 12:12:41 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:41961 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751612AbdLLRMk (ORCPT ); Tue, 12 Dec 2017 12:12:40 -0500 X-Google-Smtp-Source: ACJfBosQVObbauJxf4dSMwoQ265QflMHUzwGDFnQ8/GrwRK05OmE2/sFXrXzOgg3k5FMtZoVf8GeSw== Date: Tue, 12 Dec 2017 09:12:36 -0800 From: Richard Cochran To: Aleksey Makarov Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, "Goutham, Sunil" , Radoslaw Biernacki , Robert Richter , David Daney , Philippe Ombredanne Subject: Re: [PATCH net-next v5 1/2] net: add support for Cavium PTP coprocessor Message-ID: <20171212171236.36yn4ljbnm2c2zqf@localhost> References: <20171211141435.2915-1-aleksey.makarov@cavium.com> <20171211141435.2915-2-aleksey.makarov@cavium.com> <20171211225954.ezqut6jvfg65rg4w@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1001 Lines: 35 On Tue, Dec 12, 2017 at 12:41:35PM +0300, Aleksey Makarov wrote: > If ptp_clock_register() returns NULL, the device is still paired with the driver, > but the driver is not registered in the PTP core. When ethernet driver needs > the reference to this cavium PTP driver, it calls cavium_ptp_get() that checks > if ptp->ptp_clock is NULL and, if so, returns -ENODEV. The pointer clock->ptp_clock can be NULL. Yet you de-reference it here: > +static void cavium_ptp_remove(struct pci_dev *pdev) > +{ > + struct cavium_ptp *clock = pci_get_drvdata(pdev); > + u64 clock_cfg; > + > + pci_set_drvdata(pdev, NULL); > + > + ptp_clock_unregister(clock->ptp_clock); > + > + clock_cfg = readq(clock->reg_base + PTP_CLOCK_CFG); > + clock_cfg &= ~PTP_CLOCK_CFG_PTP_EN; > + writeq(clock_cfg, clock->reg_base + PTP_CLOCK_CFG); > +} and here: > +static inline int cavium_ptp_clock_index(struct cavium_ptp *clock) > +{ > + return ptp_clock_index(clock->ptp_clock); > +} That needs to be fixed. Thanks, Richard