Netdev List
 help / color / mirror / Atom feed
From: kbuild test robot <lkp@intel.com>
To: YueHaibing <yuehaibing@huawei.com>
Cc: kbuild-all@01.org, davem@davemloft.net, richardcochran@gmail.com,
	dmitry.torokhov@gmail.com, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org, YueHaibing <yuehaibing@huawei.com>
Subject: Re: [PATCH net-next] ptp: Fix pass zero to ERR_PTR() in ptp_clock_register
Date: Fri, 23 Nov 2018 01:30:31 +0800	[thread overview]
Message-ID: <201811230114.mywyGh81%fengguang.wu@intel.com> (raw)
In-Reply-To: <20181122133202.21908-1-yuehaibing@huawei.com>

[-- Attachment #1: Type: text/plain, Size: 7331 bytes --]

Hi YueHaibing,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url:    https://github.com/0day-ci/linux/commits/YueHaibing/ptp-Fix-pass-zero-to-ERR_PTR-in-ptp_clock_register/20181123-010251
config: x86_64-randconfig-x017-201846 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   drivers/ptp/ptp_clock.c: In function 'ptp_clock_register':
>> drivers/ptp/ptp_clock.c:269:18: warning: passing argument 1 of 'PTR_ERR' makes pointer from integer without a cast [-Wint-conversion]
       err = PTR_ERR(-EINVAL);
                     ^
   In file included from arch/x86/include/asm/processor.h:32:0,
                    from arch/x86/include/asm/cpufeature.h:8,
                    from arch/x86/include/asm/thread_info.h:53,
                    from include/linux/thread_info.h:38,
                    from arch/x86/include/asm/preempt.h:7,
                    from include/linux/preempt.h:81,
                    from include/linux/radix-tree.h:27,
                    from include/linux/idr.h:15,
                    from drivers/ptp/ptp_clock.c:20:
   include/linux/err.h:29:33: note: expected 'const void *' but argument is of type 'int'
    static inline long __must_check PTR_ERR(__force const void *ptr)
                                    ^~~~~~~
   Cyclomatic Complexity 5 include/linux/compiler.h:__write_once_size
   Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:fls64
   Cyclomatic Complexity 1 include/linux/log2.h:__ilog2_u64
   Cyclomatic Complexity 1 include/linux/list.h:INIT_LIST_HEAD
   Cyclomatic Complexity 1 include/linux/math64.h:div_u64_rem
   Cyclomatic Complexity 1 include/asm-generic/getorder.h:__get_order
   Cyclomatic Complexity 3 include/linux/string.h:memset
   Cyclomatic Complexity 1 include/linux/err.h:ERR_PTR
   Cyclomatic Complexity 1 include/linux/err.h:PTR_ERR
   Cyclomatic Complexity 1 include/linux/spinlock.h:spinlock_check
   Cyclomatic Complexity 1 include/linux/spinlock.h:spin_unlock_irqrestore
   Cyclomatic Complexity 1 include/linux/ktime.h:ktime_to_ns
   Cyclomatic Complexity 1 include/linux/slab.h:kmalloc_type
   Cyclomatic Complexity 28 include/linux/slab.h:kmalloc_index
   Cyclomatic Complexity 68 include/linux/slab.h:kmalloc_large
   Cyclomatic Complexity 4 include/linux/slab.h:kmalloc
   Cyclomatic Complexity 1 include/linux/slab.h:kzalloc
   Cyclomatic Complexity 2 drivers/ptp/ptp_private.h:queue_cnt
   Cyclomatic Complexity 1 drivers/ptp/ptp_clock.c:queue_free
   Cyclomatic Complexity 2 drivers/ptp/ptp_clock.c:enqueue_external_timestamp
   Cyclomatic Complexity 1 drivers/ptp/ptp_clock.c:scaled_ppm_to_ppb
   Cyclomatic Complexity 1 drivers/ptp/ptp_clock.c:ptp_clock_getres
   Cyclomatic Complexity 1 drivers/ptp/ptp_clock.c:ptp_clock_settime
   Cyclomatic Complexity 2 drivers/ptp/ptp_clock.c:ptp_clock_gettime
   Cyclomatic Complexity 1 drivers/ptp/ptp_clock.c:delete_ptp_clock
   Cyclomatic Complexity 2 drivers/ptp/ptp_clock.c:ptp_aux_kworker
   Cyclomatic Complexity 2 include/linux/ktime.h:ktime_set
   Cyclomatic Complexity 1 include/linux/ktime.h:timespec64_to_ktime
   Cyclomatic Complexity 9 drivers/ptp/ptp_clock.c:ptp_clock_adjtime
   Cyclomatic Complexity 1 include/linux/err.h:IS_ERR
   Cyclomatic Complexity 1 include/linux/pps_kernel.h:pps_get_ts
   Cyclomatic Complexity 1 drivers/ptp/ptp_clock.c:ptp_exit
   Cyclomatic Complexity 3 drivers/ptp/ptp_clock.c:ptp_init
   Cyclomatic Complexity 13 drivers/ptp/ptp_clock.c:ptp_clock_register
   Cyclomatic Complexity 3 drivers/ptp/ptp_clock.c:ptp_clock_unregister
   Cyclomatic Complexity 4 drivers/ptp/ptp_clock.c:ptp_clock_event
   Cyclomatic Complexity 1 drivers/ptp/ptp_clock.c:ptp_clock_index
   Cyclomatic Complexity 5 drivers/ptp/ptp_clock.c:ptp_find_pin
   Cyclomatic Complexity 1 drivers/ptp/ptp_clock.c:ptp_schedule_worker

vim +/PTR_ERR +269 drivers/ptp/ptp_clock.c

   205	
   206	struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
   207					     struct device *parent)
   208	{
   209		struct ptp_clock *ptp;
   210		int err = 0, index, major = MAJOR(ptp_devt);
   211	
   212		if (info->n_alarm > PTP_MAX_ALARMS)
   213			return ERR_PTR(-EINVAL);
   214	
   215		/* Initialize a clock structure. */
   216		err = -ENOMEM;
   217		ptp = kzalloc(sizeof(struct ptp_clock), GFP_KERNEL);
   218		if (ptp == NULL)
   219			goto no_memory;
   220	
   221		index = ida_simple_get(&ptp_clocks_map, 0, MINORMASK + 1, GFP_KERNEL);
   222		if (index < 0) {
   223			err = index;
   224			goto no_slot;
   225		}
   226	
   227		ptp->clock.ops = ptp_clock_ops;
   228		ptp->clock.release = delete_ptp_clock;
   229		ptp->info = info;
   230		ptp->devid = MKDEV(major, index);
   231		ptp->index = index;
   232		spin_lock_init(&ptp->tsevq.lock);
   233		mutex_init(&ptp->tsevq_mux);
   234		mutex_init(&ptp->pincfg_mux);
   235		init_waitqueue_head(&ptp->tsev_wq);
   236	
   237		if (ptp->info->do_aux_work) {
   238			kthread_init_delayed_work(&ptp->aux_work, ptp_aux_kworker);
   239			ptp->kworker = kthread_create_worker(0, "ptp%d", ptp->index);
   240			if (IS_ERR(ptp->kworker)) {
   241				err = PTR_ERR(ptp->kworker);
   242				pr_err("failed to create ptp aux_worker %d\n", err);
   243				goto kworker_err;
   244			}
   245		}
   246	
   247		err = ptp_populate_pin_groups(ptp);
   248		if (err)
   249			goto no_pin_groups;
   250	
   251		/* Create a new device in our class. */
   252		ptp->dev = device_create_with_groups(ptp_class, parent, ptp->devid,
   253						     ptp, ptp->pin_attr_groups,
   254						     "ptp%d", ptp->index);
   255		if (IS_ERR(ptp->dev)) {
   256			err = PTR_ERR(ptp->dev);
   257			goto no_device;
   258		}
   259	
   260		/* Register a new PPS source. */
   261		if (info->pps) {
   262			struct pps_source_info pps;
   263			memset(&pps, 0, sizeof(pps));
   264			snprintf(pps.name, PPS_MAX_NAME_LEN, "ptp%d", index);
   265			pps.mode = PTP_PPS_MODE;
   266			pps.owner = info->owner;
   267			ptp->pps_source = pps_register_source(&pps, PTP_PPS_DEFAULTS);
   268			if (!ptp->pps_source) {
 > 269				err = PTR_ERR(-EINVAL);
   270				pr_err("failed to register pps source\n");
   271				goto no_pps;
   272			}
   273		}
   274	
   275		/* Create a posix clock. */
   276		err = posix_clock_register(&ptp->clock, ptp->devid);
   277		if (err) {
   278			pr_err("failed to create posix clock\n");
   279			goto no_clock;
   280		}
   281	
   282		return ptp;
   283	
   284	no_clock:
   285		if (ptp->pps_source)
   286			pps_unregister_source(ptp->pps_source);
   287	no_pps:
   288		device_destroy(ptp_class, ptp->devid);
   289	no_device:
   290		ptp_cleanup_pin_groups(ptp);
   291	no_pin_groups:
   292		if (ptp->kworker)
   293			kthread_destroy_worker(ptp->kworker);
   294	kworker_err:
   295		mutex_destroy(&ptp->tsevq_mux);
   296		mutex_destroy(&ptp->pincfg_mux);
   297		ida_simple_remove(&ptp_clocks_map, index);
   298	no_slot:
   299		kfree(ptp);
   300	no_memory:
   301		return ERR_PTR(err);
   302	}
   303	EXPORT_SYMBOL(ptp_clock_register);
   304	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 28309 bytes --]

  reply	other threads:[~2018-11-22 17:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-22 13:32 [PATCH net-next] ptp: Fix pass zero to ERR_PTR() in ptp_clock_register YueHaibing
2018-11-22 17:30 ` kbuild test robot [this message]
2018-11-23  1:24   ` YueHaibing

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201811230114.mywyGh81%fengguang.wu@intel.com \
    --to=lkp@intel.com \
    --cc=davem@davemloft.net \
    --cc=dmitry.torokhov@gmail.com \
    --cc=kbuild-all@01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    --cc=yuehaibing@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox