From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S971350AbdDTU2j (ORCPT ); Thu, 20 Apr 2017 16:28:39 -0400 Received: from mout.web.de ([212.227.17.11]:58893 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S970878AbdDTU2f (ORCPT ); Thu, 20 Apr 2017 16:28:35 -0400 Subject: [PATCH 2/2] firewire: ohci: Adjust 15 checks for null pointers From: SF Markus Elfring To: linux1394-devel@lists.sourceforge.net, Stefan Richter Cc: LKML , kernel-janitors@vger.kernel.org References: <1139a329-f084-c4f3-d9af-19ad15445017@users.sourceforge.net> Message-ID: <595c593e-8a24-24da-0731-e317bbf91d56@users.sourceforge.net> Date: Thu, 20 Apr 2017 22:28:12 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0.1 MIME-Version: 1.0 In-Reply-To: <1139a329-f084-c4f3-d9af-19ad15445017@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:Y2r5Vj+bxoPpJc3TkgS1y9xGnyDmZkMGuLmNRMuTG/Zzc9+FKT5 cSVxqiS1Lq6iUefDykv800+r7ZKLc7HuR4wJKFb9Yy53ntGud74qk9MWceUZL/9QQxFHPZb HUVEuWq5+FhZe5upkCJsF/cMLktCd8vHy7fwqsXhg6iBH7L0+D48ZnwYXYZMtLWFZk/qVuv mEs1jYmbgiJe5O6p4Ew3Q== X-UI-Out-Filterresults: notjunk:1;V01:K0:rJseX0cRYFg=:Gx5wn1rSEBsjS8/dfLy5a8 /jG/eHoYc2ptXxqN9FuBOVcFUNMfBt4+3O7H2DCK2vYOUf0KNnlypcAHCDv8JynCLI+i0jXC9 CaIazIBnVces68w3uNzPJ2WnmM09Gkl5+SY2aF+UTiDI8bW2+Bh70jc1afcee7hwomjCXBnUy rfJO3h1QzA1v3rARlYTuhO76OG0T3pael6MqFfVsEVZ8S1d3gK1UEZWWyIOnPKL8XZ7yY/gBe 6XX3oHnuA5Ld7+J4MmiBKsCusXp8ok1e4ygiuQpWoRBsf+ZV/3zI4dvbEr/rRAVb1SnQTviwn ppo6yO/CdeqQtSGldV5fLkbOWFRk++aI2CPj5Bdje8zqqXEZbjWOQ217A0HiHeHFPopyzp7FP +mmRISu0fMw8jP+o8/X1TKEvq49hV88aNUy2Y9jaZLo1mhaxGw6cv9RJFf6MLdb/1Gf/kRw6o q67WSm1sW/zWqWRXTW8bmBjOucW1cbsNqqWbjfbDlEuUDHy3sQIu61kQqSWP7IgDuK3Oj9DbH rt5siRev2CKc3ZWcDqNrTsowPetnVE67DzcnvbS7vkFhOfJqYNj5WJ+PGi0CUP0TDmP9L69gv z77LVp7pHoI8pYjKdmcjLCQ6py5nUnutAQ2LpwCm/i4UPONsSTSBLdZdC2LYLJUfQKjfgtBfs hgMuh+pbwseLa4cTqVy3hLxnjsAaS88claYdxv4PMB1Wqitt1xWNuKh2ZzVJb/qviSkg1HzC2 6nQ/X7oLDeAowFylFg8H50cB2K5fIQfgtWaxhI8ITBA+M00qj32C4a6DGZQgh8fNNl3D+S3h3 eUC7sZH Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Thu, 20 Apr 2017 22:10:29 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The script “checkpatch.pl” pointed information out like the following. Comparison to NULL could be written … Thus fix the affected source code places. Signed-off-by: Markus Elfring --- drivers/firewire/ohci.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index 30be5dbd5b09..165600c74b7c 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c @@ -1305,7 +1305,7 @@ static int at_context_queue_packet(struct context *ctx, int z, tcode; d = context_get_descriptors(ctx, 4, &d_bus); - if (d == NULL) { + if (!d) { packet->ack = RCODE_SEND_ERROR; return -1; } @@ -1450,7 +1450,7 @@ static int handle_at_packet(struct context *context, driver_data = (struct driver_data *) &d[3]; packet = driver_data->packet; - if (packet == NULL) + if (!packet) /* This packet was cancelled, just continue. */ return 1; @@ -2027,7 +2027,7 @@ static void bus_reset_work(struct work_struct *work) * next_config_rom pointer so a new update can take place. */ - if (ohci->next_config_rom != NULL) { + if (ohci->next_config_rom) { if (ohci->next_config_rom != ohci->config_rom) { free_rom = ohci->config_rom; free_rom_bus = ohci->config_rom_bus; @@ -2394,7 +2394,7 @@ static int ohci_enable(struct fw_card *card, dma_alloc_coherent(ohci->card.device, CONFIG_ROM_SIZE, &ohci->next_config_rom_bus, GFP_KERNEL); - if (ohci->next_config_rom == NULL) + if (!ohci->next_config_rom) return -ENOMEM; copy_config_rom(ohci->next_config_rom, config_rom, length); @@ -2488,7 +2488,7 @@ static int ohci_set_config_rom(struct fw_card *card, next_config_rom = dma_alloc_coherent(ohci->card.device, CONFIG_ROM_SIZE, &next_config_rom_bus, GFP_KERNEL); - if (next_config_rom == NULL) + if (!next_config_rom) return -ENOMEM; spin_lock_irq(&ohci->lock); @@ -2504,7 +2504,7 @@ static int ohci_set_config_rom(struct fw_card *card, * let this routine free the unused DMA allocation. */ - if (ohci->next_config_rom == NULL) { + if (!ohci->next_config_rom) { ohci->next_config_rom = next_config_rom; ohci->next_config_rom_bus = next_config_rom_bus; next_config_rom = NULL; @@ -2520,7 +2520,7 @@ static int ohci_set_config_rom(struct fw_card *card, spin_unlock_irq(&ohci->lock); /* If we didn't use the DMA allocation, delete it. */ - if (next_config_rom != NULL) + if (next_config_rom) dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE, next_config_rom, next_config_rom_bus); @@ -3001,7 +3001,7 @@ static struct fw_iso_context *ohci_allocate_iso_context(struct fw_card *card, memset(ctx, 0, sizeof(*ctx)); ctx->header_length = 0; ctx->header = (void *) __get_free_page(GFP_KERNEL); - if (ctx->header == NULL) { + if (!ctx->header) { ret = -ENOMEM; goto out; } @@ -3235,7 +3235,7 @@ static int queue_iso_transmit(struct iso_context *ctx, header_z = DIV_ROUND_UP(p->header_length, sizeof(*d)); d = context_get_descriptors(&ctx->context, z + header_z, &d_bus); - if (d == NULL) + if (!d) return -ENOMEM; if (!p->skip) { @@ -3333,7 +3333,7 @@ static int queue_iso_packet_per_buffer(struct iso_context *ctx, z = DIV_ROUND_UP(payload_per_buffer + offset, PAGE_SIZE) + 1; d = context_get_descriptors(&ctx->context, z + header_z, &d_bus); - if (d == NULL) + if (!d) return -ENOMEM; d->control = cpu_to_le16(DESCRIPTOR_STATUS | @@ -3405,7 +3405,7 @@ static int queue_iso_buffer_fill(struct iso_context *ctx, for (i = 0; i < z; i++) { d = context_get_descriptors(&ctx->context, 1, &d_bus); - if (d == NULL) + if (!d) return -ENOMEM; d->control = cpu_to_le16(DESCRIPTOR_INPUT_MORE | @@ -3572,7 +3572,7 @@ static int pci_probe(struct pci_dev *dev, } ohci = kzalloc(sizeof(*ohci), GFP_KERNEL); - if (ohci == NULL) { + if (!ohci) { err = -ENOMEM; goto fail; } @@ -3610,7 +3610,7 @@ static int pci_probe(struct pci_dev *dev, } ohci->registers = pci_iomap(dev, 0, OHCI1394_REGISTER_SIZE); - if (ohci->registers == NULL) { + if (!ohci->registers) { ohci_err(ohci, "failed to remap registers\n"); err = -ENXIO; goto fail_iomem; @@ -3686,7 +3686,7 @@ static int pci_probe(struct pci_dev *dev, ohci->it_context_list = kcalloc(ohci->n_it, sizeof(*ohci->it_context_list), GFP_KERNEL); - if (ohci->it_context_list == NULL || ohci->ir_context_list == NULL) { + if (!ohci->it_context_list || !ohci->ir_context_list) { err = -ENOMEM; goto fail_contexts; } -- 2.12.2