From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033900AbdEWUzZ (ORCPT ); Tue, 23 May 2017 16:55:25 -0400 Received: from mout.web.de ([212.227.15.4]:55939 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033549AbdEWUzT (ORCPT ); Tue, 23 May 2017 16:55:19 -0400 Subject: [PATCH 5/5] MIPS: VPE: Adjust 13 checks for null pointers From: SF Markus Elfring To: linux-mips@linux-mips.org, Ingo Molnar , James Hogan , Kees Cook , Marcin Nowakowski , Masahiro Yamada , Matt Redfearn , Paul Burton , =?UTF-8?Q?Ralf_B=c3=a4chle?= , Thomas Gleixner Cc: LKML , kernel-janitors@vger.kernel.org References: Message-ID: <44ff74fa-07c9-3f9c-6cda-050296400c72@users.sourceforge.net> Date: Tue, 23 May 2017 22:55:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:yPvDQl6pjUolNxu/dhY1DvynVgKAzWspOWQrYHe38U6No4p6hu2 WTHgMYxbcAJjycGCGKacyAlhtOqC5pazZSbGNARRHXtzOYTYke6pyaVT6AZr1HaiRGy/GS6 pVX4p/ulOpgtH2r0ylRLQLGgOM8LN19qwJxiU1/zZBmZWr9T2VXRdBlk15QVzpfMBwv+7eX o7XCD9aeDg6XL3eSbt1Cg== X-UI-Out-Filterresults: notjunk:1;V01:K0:ZDM7CKNoh8E=:X8rpTJDrStXmpafA5+SFOA tkJrJChoNgUWH5gGqCloWe+nethcCqmZiXOQMWlk1e6ptAOkqcRO451aygR3fkMZRfNuodZlp 1iY5y7t8gOcJu4jDlRuPi6x2pAbhSEhqIoL4Inbdkdi8L9KvkhY1YkyPgi16swSZD+xcNMG4l OE89G5O75ntFdZiqpE0Yns5Z8vprBAsMWyW1jpFKBNvVGq6Ne++npt/FyfEE61YVOlgVcHeZA BMiZIgWU+BLMxie+Nf48kn496VjZBugQzGPAHVzt6m3fCMPOP2zEDX+Dbq2IlRG8jFkIz1BQD busnHm1bU8A8zr3NKvxMvMBCSjVJPDrGWVG0jkvn14/19emItQta/0c2j7IaUDSpGnCqyraxu CgIFPyKtr5tAjA9yZK3fCil/kFRNVGpEkcBH9SGto0WvQmMMotXiGGg3CIpBbHe5fnPykMa8H 8gEPq0Jb8OzvU+1L1ElkyaECW/6VHrXU/hvQWQ3K+sv/w0i3Vvgv1EpTl/bM2fuFglPcAljNR T8wpOpV1KZN07ziKO1ufdoPooWeDoxGnaRG+nrTO3i/PejUGYZ68bR61IoiqU7dchNI/cY4c9 rVvtEkrwgTbiGQml8neXmnCjIUJ/ZtwJIs+W6s7G5huPCsSJMM2rYveZGqKCvrJOWDFW2oOcr vcak6DyYvfeugfpaakvaANd2UC+QF+h0juf7HIBUugr69P9/5jmNturJ0eO7RDBxc8qqf70GW tQZ/AXj/uV2c6dNtKZ8o2Kkg4a6wZ4NYlo/q4abo9aHJC8xBuwIi3J8GD3qaZLGdNnrvfk2uw 6YQeBEf Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Tue, 23 May 2017 22:16:24 +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 --- arch/mips/kernel/vpe.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/arch/mips/kernel/vpe.c b/arch/mips/kernel/vpe.c index ed019218496b..0ef7654e67e4 100644 --- a/arch/mips/kernel/vpe.c +++ b/arch/mips/kernel/vpe.c @@ -97,4 +97,4 @@ struct vpe *alloc_vpe(int minor) - if (v == NULL) + if (!v) goto out; INIT_LIST_HEAD(&v->tc); @@ -118,4 +118,4 @@ struct tc *alloc_tc(int index) - if (tc == NULL) + if (!tc) goto out; INIT_LIST_HEAD(&tc->tc); @@ -340,10 +340,9 @@ static int apply_r_mips_lo16(struct module *me, uint32_t *location, /* Sign extend the addend we extract from the lo insn. */ vallo = ((insnlo & 0xffff) ^ 0x8000) - 0x8000; - if (mips_hi16_list != NULL) { - + if (mips_hi16_list) { l = mips_hi16_list; - while (l != NULL) { + while (l) { unsigned long insn; /* @@ -391,7 +390,7 @@ static int apply_r_mips_lo16(struct module *me, uint32_t *location, return 0; out_free: - while (l != NULL) { + while (l) { next = l->next; kfree(l); l = next; @@ -562,7 +561,7 @@ static int find_vpe_symbols(struct vpe *v, Elf_Shdr *sechdrs, v->shared_ptr = (void *)sym[i].st_value; } - if ((v->__start == 0) || (v->shared_ptr == NULL)) + if ((v->__start == 0) || !v->shared_ptr) return -1; return 0; @@ -737,7 +736,7 @@ static int vpe_elfload(struct vpe *v) return -ENOEXEC; } - if (v->shared_ptr == NULL) + if (!v->shared_ptr) pr_warn("VPE loader: program does not contain vpe_shared symbol.\n" " Unable to use AMVP (AP/SP) facilities.\n"); } @@ -777,7 +776,7 @@ static int vpe_open(struct inode *inode, struct file *filp) } v = get_vpe(aprp_cpu_index()); - if (v == NULL) { + if (!v) { pr_warn("VPE loader: unable to get vpe\n"); return -ENODEV; @@ -822,7 +821,7 @@ static int vpe_release(struct inode *inode, struct file *filp) int ret = 0; v = get_vpe(aprp_cpu_index()); - if (v == NULL) + if (!v) return -ENODEV; hdr = (Elf_Ehdr *) v->pbuffer; @@ -866,8 +865,7 @@ static ssize_t vpe_write(struct file *file, const char __user *buffer, return -ENODEV; v = get_vpe(aprp_cpu_index()); - - if (v == NULL) + if (!v) return -ENODEV; if ((count + v->len) > v->plen) { @@ -895,7 +893,7 @@ void *vpe_get_shared(int index) { struct vpe *v = get_vpe(index); - if (v == NULL) + if (!v) return NULL; return v->shared_ptr; @@ -906,7 +904,7 @@ int vpe_notify(int index, struct vpe_notifications *notify) { struct vpe *v = get_vpe(index); - if (v == NULL) + if (!v) return -1; list_add(¬ify->list, &v->notify); @@ -918,7 +916,7 @@ char *vpe_getcwd(int index) { struct vpe *v = get_vpe(index); - if (v == NULL) + if (!v) return NULL; return v->cwd; -- 2.13.0