Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934960AbeAIScf (ORCPT + 1 other); Tue, 9 Jan 2018 13:32:35 -0500 Received: from mout.web.de ([212.227.15.14]:57872 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934942AbeAIScd (ORCPT ); Tue, 9 Jan 2018 13:32:33 -0500 Subject: [PATCH 4/5] misc/pti: Adjust 11 checks for null pointers From: SF Markus Elfring To: kernel-janitors@vger.kernel.org, Arnd Bergmann , Greg Kroah-Hartman Cc: LKML References: Message-ID: Date: Tue, 9 Jan 2018 19:32:29 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 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:l4silo9SvWSppjeRvsAT9UWUwURRyiqTD5ZFKMSUDm9nfPd32kn +YGprjNM4VBDQmhu55BnJDwev7C8arIaICnbKY0DuMKq6QW7ekmu+88P++BdiOkcylSjmll IUroLDqwDFCXE6d8KEVugkBkiT5I6YvanwNlfcbQ6DKznnJiGBg1zr4zfThlshIzVT93Vld 7vojPbUP4o2VlEofcNGgA== X-UI-Out-Filterresults: notjunk:1;V01:K0:mzKb4F/hvLw=:C+/zQ6eX285+nc4g7zLsth rIUqFfqAbnTyiYzYY4xCz3zoZuqUM+71mhunZmJMDj1HFV60bg6wPm4j47dd1zY/3YgW5X+Iu oU/kpZtuWb7SdxfzBF9gU5VwPqjFcYv1bK0tbQwNcEG3RXZpqVMAmVLf/hg+i0Wp0E+LUSAmj +hr1DlFghguM6PaZz4fnQ3Wc5KQj73wxQ+9AXvU5NGyjokfnXs3OjEpnyd99j8T6zOsOrddiB ryxI1bQguPvgBzPnNL0uSQpMtIwNlGG7UHoxFjfITHHigQz65mjZTmAxk9aGgnmpXy6G4J9Lb A1EoYjL0Pscud3oCOz/1QqXOhiaOJ4yGRep/DBasUCzvP2vORcX6zEAHn7wyE+Fs+6FpStsWq //bSVgmX+2+G2qAJ4HyNwB5dyzlaGKmsvJS+DqoLZe++BSk8O8ldt6esgUWm391R5PsdeXorj 9kXvD4HH/w6EovwXklnyR+G/mzWQ7vG98DlDwGK1KqvJkraMiSpXgKtt3+Q6m3UmdY823zzjt jtXzqxZKT4ufiHydU3irJkZHqkObqzkKTT+RKhng+M5TByxIB5BmSbHLhAI2lxDt/no9rgA06 qgPQOenv8h/ITn1VAHMDC/LvvHgD3r27855LjHhnAtiaOJRMngsc+9RBs00n5X5NYSkZaVFwR TmkdgmgbFM1jYkq6+f2nQgAS/5eMm/v4gi7RpdTXJVDwB6snpP9ShodxkxgveZeZvbQPm0yrA kJZ4+K6f0wRQGLoOqkmHoW4ksuWA/p94xrcIVa8+gGhh7mYH4HWN5BEvGby8vfwoq3bY61q7v 6QJcetbuNYCmAiHVG62K6ZHtlnaI20VSbMNNkfnE6a6I49r7dY= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: From: Markus Elfring Date: Tue, 9 Jan 2018 18:48:10 +0100 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/misc/pti.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/misc/pti.c b/drivers/misc/pti.c index 8ae79b286573..11d92c3f43ba 100644 --- a/drivers/misc/pti.c +++ b/drivers/misc/pti.c @@ -246,7 +246,7 @@ static struct pti_masterchannel *get_id(u8 *id_array, int i, j, mask; struct pti_masterchannel *mc = kmalloc(sizeof(*mc), GFP_KERNEL); - if (mc == NULL) + if (!mc) return NULL; /* look for a byte with a free bit */ @@ -386,5 +386,5 @@ void pti_writedata(struct pti_masterchannel *mc, u8 *buf, int count) * API function, thus, all parameters should * be checked for validity. */ - if ((mc != NULL) && (buf != NULL) && (count > 0)) + if (mc && buf && count > 0) pti_write_to_aperture(mc, buf, count); @@ -465,7 +465,7 @@ static int pti_tty_install(struct tty_driver *driver, struct tty_struct *tty) if (ret == 0) { pti_tty_data = kmalloc(sizeof(*pti_tty_data), GFP_KERNEL); - if (pti_tty_data == NULL) + if (!pti_tty_data) return -ENOMEM; if (idx == PTITTY_MINOR_START) @@ -473,7 +473,7 @@ static int pti_tty_install(struct tty_driver *driver, struct tty_struct *tty) else pti_tty_data->mc = pti_request_masterchannel(2, NULL); - if (pti_tty_data->mc == NULL) { + if (!pti_tty_data->mc) { kfree(pti_tty_data); return -ENXIO; } @@ -492,7 +492,8 @@ static int pti_tty_install(struct tty_driver *driver, struct tty_struct *tty) static void pti_tty_cleanup(struct tty_struct *tty) { struct pti_tty *pti_tty_data = tty->driver_data; - if (pti_tty_data == NULL) + + if (!pti_tty_data) return; pti_release_masterchannel(pti_tty_data->mc); kfree(pti_tty_data); @@ -516,7 +517,8 @@ static int pti_tty_driver_write(struct tty_struct *tty, const unsigned char *buf, int len) { struct pti_tty *pti_tty_data = tty->driver_data; - if ((pti_tty_data != NULL) && (pti_tty_data->mc != NULL)) { + + if (pti_tty_data && pti_tty_data->mc) { pti_write_to_aperture(pti_tty_data->mc, (u8 *)buf, len); return len; } @@ -561,7 +563,7 @@ static int pti_char_open(struct inode *inode, struct file *filp) * Slightly easier to debug if this driver needs debugging. */ mc = pti_request_masterchannel(0, NULL); - if (mc == NULL) + if (!mc) return -ENOMEM; filp->private_data = mc; return 0; @@ -820,7 +822,7 @@ static int pti_pci_probe(struct pci_dev *pdev, } drv_data = kzalloc(sizeof(*drv_data), GFP_KERNEL); - if (drv_data == NULL) { + if (!drv_data) { retval = -ENOMEM; goto err_disable_pci; } @@ -916,7 +918,7 @@ static int __init pti_init(void) /* First register module as tty device */ pti_tty_driver = alloc_tty_driver(PTITTY_MINOR_NUM); - if (pti_tty_driver == NULL) { + if (!pti_tty_driver) { pr_err("%s(%d): Memory allocation failed for ptiTTY driver\n", __func__, __LINE__); return -ENOMEM; -- 2.15.1