[bug report] cross-tree: phase out dma_zalloc_coherent()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ancient code leads to this static checker warning:

	drivers/scsi/mvumi.c:130 mvumi_alloc_mem_resource()
	warn: sleeping in atomic context

drivers/scsi/mvumi.c
    106 static struct mvumi_res *mvumi_alloc_mem_resource(struct mvumi_hba *mhba,
    107 				enum resource_type type, unsigned int size)
    108 {
    109 	struct mvumi_res *res = kzalloc(sizeof(*res), GFP_ATOMIC);
                                                              ^^^^^^^^^^
These allocations are atomic.

    110 
    111 	if (!res) {
    112 		dev_err(&mhba->pdev->dev,
    113 			"Failed to allocate memory for resource manager.\n");
    114 		return NULL;
    115 	}
    116 
    117 	switch (type) {
    118 	case RESOURCE_CACHED_MEMORY:
    119 		res->virt_addr = kzalloc(size, GFP_ATOMIC);
                                                       ^^^^^^^^^^

    120 		if (!res->virt_addr) {
    121 			dev_err(&mhba->pdev->dev,
    122 				"unable to allocate memory,size = %d.\n", size);
    123 			kfree(res);
    124 			return NULL;
    125 		}
    126 		break;
    127 
    128 	case RESOURCE_UNCACHED_MEMORY:
    129 		size = round_up(size, 8);
--> 130 		res->virt_addr = dma_alloc_coherent(&mhba->pdev->dev, size,
    131 						    &res->bus_addr,
    132 						    GFP_KERNEL);
                                                            ^^^^^^^^^^
Should this be as well?  The call tree is:

mvumi_isr_handler() <- disables preempt
-> mvumi_handshake()
   -> mvumi_init_data()
      -> mvumi_alloc_mem_resource()

    133 		if (!res->virt_addr) {
    134 			dev_err(&mhba->pdev->dev,
    135 					"unable to allocate consistent mem,"
    136 							"size = %d.\n", size);
    137 			kfree(res);
    138 			return NULL;
    139 		}
    140 		break;
    141 
    142 	default:
    143 		dev_err(&mhba->pdev->dev, "unknown resource type %d.\n", type);
    144 		kfree(res);
    145 		return NULL;
    146 	}
    147 
    148 	res->type = type;
    149 	res->size = size;
    150 	INIT_LIST_HEAD(&res->entry);
    151 	list_add_tail(&res->entry, &mhba->res_list);
    152 
    153 	return res;
    154 }

regards,
dan carpenter



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux