lkml.org 
[lkml]   [2018]   [Apr]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/1] scsi: mvsas:fix memory leak
Hi Xidong,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on mkp-scsi/for-next]
[also build test WARNING on v4.16 next-20180403]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Xidong-Wang/scsi-mvsas-fix-memory-leak/20180404-182132
base: https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
config: x86_64-randconfig-x010-201813 (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/scsi//mvsas/mv_init.c: In function 'mvs_pci_alloc':
>> drivers/scsi//mvsas/mv_init.c:373:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
if (!mvi)
^~
drivers/scsi//mvsas/mv_init.c:375:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
return NULL;
^~~~~~
Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:test_and_set_bit
Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:fls64
Cyclomatic Complexity 1 include/linux/log2.h:__ilog2_u64
Cyclomatic Complexity 1 include/linux/mem_encrypt.h:sme_get_me_mask
Cyclomatic Complexity 1 include/asm-generic/getorder.h:__get_order
Cyclomatic Complexity 1 arch/x86/include/asm/paravirt.h:arch_local_save_flags
Cyclomatic Complexity 1 arch/x86/include/asm/irqflags.h:arch_irqs_disabled_flags
Cyclomatic Complexity 1 include/linux/device.h:dev_get_drvdata
Cyclomatic Complexity 1 include/linux/device.h:dev_set_drvdata
Cyclomatic Complexity 1 include/linux/dma-debug.h:debug_dma_free_coherent
Cyclomatic Complexity 1 arch/x86/include/asm/dma-mapping.h:get_arch_dma_ops
Cyclomatic Complexity 4 include/linux/dma-mapping.h:get_dma_ops
Cyclomatic Complexity 1 include/linux/kasan.h:kasan_kmalloc
Cyclomatic Complexity 28 include/linux/slab.h:kmalloc_index
Cyclomatic Complexity 1 include/linux/slab.h:kmem_cache_alloc_trace
Cyclomatic Complexity 1 include/linux/slab.h:kmalloc_order_trace
Cyclomatic Complexity 68 include/linux/slab.h:kmalloc_large
Cyclomatic Complexity 5 include/linux/slab.h:kmalloc
Cyclomatic Complexity 1 include/linux/slab.h:kzalloc
Cyclomatic Complexity 1 include/linux/pci.h:pci_get_drvdata
Cyclomatic Complexity 1 include/linux/pci.h:pci_set_drvdata
Cyclomatic Complexity 5 drivers/scsi//mvsas/mv_init.c:mvs_post_sas_ha_init
Cyclomatic Complexity 8 drivers/scsi//mvsas/mv_init.c:mvs_store_interrupt_coalescing
Cyclomatic Complexity 1 drivers/scsi//mvsas/mv_init.c:mvs_show_interrupt_coalescing
Cyclomatic Complexity 1 drivers/scsi//mvsas/mv_init.c:mvs_show_driver_version
Cyclomatic Complexity 1 arch/x86/include/asm/io.h:ioremap
Cyclomatic Complexity 1 drivers/scsi//mvsas/mv_init.c:mvs_exit
Cyclomatic Complexity 2 drivers/scsi//mvsas/mv_init.c:mvs_pci_alloc
Cyclomatic Complexity 4 include/linux/dma-mapping.h:dma_free_attrs
Cyclomatic Complexity 1 include/linux/dma-mapping.h:dma_free_coherent
Cyclomatic Complexity 13 drivers/scsi//mvsas/mv_init.c:mvs_free
Cyclomatic Complexity 2 drivers/scsi//mvsas/mv_init.c:mvs_pci_remove
Cyclomatic Complexity 3 drivers/scsi//mvsas/mv_init.c:mvs_tasklet
Cyclomatic Complexity 2 include/linux/interrupt.h:tasklet_schedule
Cyclomatic Complexity 3 drivers/scsi//mvsas/mv_init.c:mvs_interrupt
Cyclomatic Complexity 4 include/linux/dma-mapping.h:dma_supported
Cyclomatic Complexity 3 include/linux/dma-mapping.h:dma_check_mask
Cyclomatic Complexity 3 include/linux/dma-mapping.h:dma_set_mask
Cyclomatic Complexity 1 include/linux/pci-dma-compat.h:pci_set_dma_mask
Cyclomatic Complexity 2 include/linux/dma-mapping.h:dma_set_coherent_mask
Cyclomatic Complexity 1 include/linux/pci-dma-compat.h:pci_set_consistent_dma_mask
Cyclomatic Complexity 6 drivers/scsi//mvsas/mv_init.c:pci_go_64
Cyclomatic Complexity 5 include/linux/slab.h:kmalloc_array
Cyclomatic Complexity 1 include/linux/slab.h:kcalloc
Cyclomatic Complexity 3 drivers/scsi//mvsas/mv_init.c:mvs_prep_sas_ha_init
Cyclomatic Complexity 2 drivers/scsi//mvsas/mv_init.c:mvs_init_sas_add
Cyclomatic Complexity 1 include/scsi/scsi_host.h:scsi_add_host
Cyclomatic Complexity 1 include/linux/interrupt.h:request_irq
Cyclomatic Complexity 13 drivers/scsi//mvsas/mv_init.c:mvs_pci_init
Cyclomatic Complexity 3 drivers/scsi//mvsas/mv_init.c:mvs_init
Cyclomatic Complexity 13 drivers/scsi//mvsas/mv_init.c:mvs_ioremap
Cyclomatic Complexity 1 drivers/scsi//mvsas/mv_init.c:mvs_iounmap

vim +/if +373 drivers/scsi//mvsas/mv_init.c

20b09c29 Andy Yan 2009-05-08 362
6f039790 Greg Kroah-Hartman 2012-12-21 363 static struct mvs_info *mvs_pci_alloc(struct pci_dev *pdev,
20b09c29 Andy Yan 2009-05-08 364 const struct pci_device_id *ent,
20b09c29 Andy Yan 2009-05-08 365 struct Scsi_Host *shost, unsigned int id)
20b09c29 Andy Yan 2009-05-08 366 {
84fbd0ce Xiangliang Yu 2011-05-24 367 struct mvs_info *mvi = NULL;
20b09c29 Andy Yan 2009-05-08 368 struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
20b09c29 Andy Yan 2009-05-08 369
b89e8f53 Xiangliang Yu 2011-05-24 370 mvi = kzalloc(sizeof(*mvi) +
b89e8f53 Xiangliang Yu 2011-05-24 371 (1L << mvs_chips[ent->driver_data].slot_width) *
b89e8f53 Xiangliang Yu 2011-05-24 372 sizeof(struct mvs_slot_info), GFP_KERNEL);
20b09c29 Andy Yan 2009-05-08 @373 if (!mvi)
549079d1 Xidong Wang 2018-04-04 374 scsi_host_put(shost);
20b09c29 Andy Yan 2009-05-08 375 return NULL;
dd4969a8 Jeff Garzik 2009-05-08 376
20b09c29 Andy Yan 2009-05-08 377 mvi->pdev = pdev;
20b09c29 Andy Yan 2009-05-08 378 mvi->dev = &pdev->dev;
20b09c29 Andy Yan 2009-05-08 379 mvi->chip_id = ent->driver_data;
20b09c29 Andy Yan 2009-05-08 380 mvi->chip = &mvs_chips[mvi->chip_id];
20b09c29 Andy Yan 2009-05-08 381 INIT_LIST_HEAD(&mvi->wq_list);
20b09c29 Andy Yan 2009-05-08 382
20b09c29 Andy Yan 2009-05-08 383 ((struct mvs_prv_info *)sha->lldd_ha)->mvi[id] = mvi;
20b09c29 Andy Yan 2009-05-08 384 ((struct mvs_prv_info *)sha->lldd_ha)->n_phy = mvi->chip->n_phy;
20b09c29 Andy Yan 2009-05-08 385
20b09c29 Andy Yan 2009-05-08 386 mvi->id = id;
20b09c29 Andy Yan 2009-05-08 387 mvi->sas = sha;
20b09c29 Andy Yan 2009-05-08 388 mvi->shost = shost;
20b09c29 Andy Yan 2009-05-08 389
b89e8f53 Xiangliang Yu 2011-05-24 390 mvi->tags = kzalloc(MVS_CHIP_SLOT_SZ>>3, GFP_KERNEL);
b89e8f53 Xiangliang Yu 2011-05-24 391 if (!mvi->tags)
b89e8f53 Xiangliang Yu 2011-05-24 392 goto err_out;
b89e8f53 Xiangliang Yu 2011-05-24 393
20b09c29 Andy Yan 2009-05-08 394 if (MVS_CHIP_DISP->chip_ioremap(mvi))
20b09c29 Andy Yan 2009-05-08 395 goto err_out;
20b09c29 Andy Yan 2009-05-08 396 if (!mvs_alloc(mvi, shost))
20b09c29 Andy Yan 2009-05-08 397 return mvi;
dd4969a8 Jeff Garzik 2009-05-08 398 err_out:
dd4969a8 Jeff Garzik 2009-05-08 399 mvs_free(mvi);
dd4969a8 Jeff Garzik 2009-05-08 400 return NULL;
dd4969a8 Jeff Garzik 2009-05-08 401 }
dd4969a8 Jeff Garzik 2009-05-08 402

:::::: The code at line 373 was first introduced by commit
:::::: 20b09c2992fefbe78f8cede7b404fb143a413c52 [SCSI] mvsas: add support for 94xx; layout change; bug fixes

:::::: TO: Andy Yan <ayan@marvell.com>
:::::: CC: James Bottomley <James.Bottomley@HansenPartnership.com>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[unhandled content-type:application/gzip]
\
 
 \ /
  Last update: 2018-04-04 13:41    [W:0.046 / U:1.332 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site