From patchwork Wed May 17 15:47:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9731513 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E0C2360363 for ; Wed, 17 May 2017 15:47:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2C88281F9 for ; Wed, 17 May 2017 15:47:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C7506283F2; Wed, 17 May 2017 15:47:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74343281F9 for ; Wed, 17 May 2017 15:47:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752075AbdEQPrh (ORCPT ); Wed, 17 May 2017 11:47:37 -0400 Received: from mout.web.de ([212.227.15.3]:59735 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751789AbdEQPrg (ORCPT ); Wed, 17 May 2017 11:47:36 -0400 Received: from [192.168.1.3] ([78.48.117.83]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MAMTy-1dI8zI1s5a-00BeSn; Wed, 17 May 2017 17:47:30 +0200 Subject: [PATCH 2/2] spidev: Adjust five checks for null pointers From: SF Markus Elfring To: linux-spi@vger.kernel.org, Mark Brown Cc: LKML , kernel-janitors@vger.kernel.org References: Message-ID: Date: Wed, 17 May 2017 17:47:29 +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-Language: en-US X-Provags-ID: V03:K0:Zdk0YJR0GMwO9QKyYfak/NnALkUMPT6ruwbrL5wGyx/0B2/RPQh iS/XNOHbvKneX8lO2uWvvbNOXuduK6okMQWB3FUOxIilVgU2K4Uxy8X4mu9td1auUovn7b6 pFEMAT9D/WdrlGf4+MO9DL1ejQ0kb3dAJiN4fwrunF/aYfXyLFaGK6M1TCVCnfIeY38flQk KR+5yDBYp2ch8bBHZ5dfw== X-UI-Out-Filterresults: notjunk:1; V01:K0:wohXIds693Q=:tYedjE9Uexbv3x/sWxjNL8 Mcqp38AWE0v1yju3fwB02T5/4Kq6ydg5FfCNsIC6D3bCKrV2r/Dg9avqGCcGOY7qE6NpFnToO DpwWOPlTtEPhjqr/Ohy2Hmc7k+uL3PLwWo14iptdii5Y4f3UKt/QPsWppr0uyX6xhIHCp+mvY 6MVWcdv0YrOvLQKwcmBfjKcaThlOk7+umh+b+g84nB0msINvCaZASjallFp0ZvV1PTeoTl9Y0 eR0Pf3sQTD2//q5FRxDc0UFhTSKOlzGoU6SXrpZ+cV+9aAz/8X8EGiC8iDw6RD0HjAFhJ5xDS Zd52MJXNpXK+/nEuFOp5V00knhbCK6H8iZqMhqzXJAOWQeiSrVbMeqIkw3ERRP7aL+FErfPw2 NORVid2WXvecYsm4arO7n/vcUC2f/0OcBKEoQCBaTL4BM1iecdUHY8iqykNK3aTxRT9y5pJyj 9n/Vmwfg9Uvhwp59h9gkHlh0JbeZCOJzgnEFgp/HWrd4LoSEPS5TG6h1FeV1cbOzW9GVF1auB DEt1ez6MI6oAbInBzgoxH7qrW3Gtn0X3TVvN6XvrXoiMzw5A1QXVd+Whqev80KsRTZn+c30WO 5YLLx0lVIQ26C6Dbwt+gWHo5ZPv8lmoH9MWdBR3i55ppiL0Fc9mLBBN2yPcuASIT6V3/m3+jD RGDYug+kdBCspa3EiCXX/J5iuKpzi4CIRiP8/Uom8hh8+hsAIwC92CV9sXhnyZNf/rrTxwwtm 5QmDwOsG1wPErPc2kbHZE0lQxfctH+/xCT9QuofuUvtXoHXHWPk99rbq6eX7eRuW29KOCGMUP 2VEY8FQ Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Wed, 17 May 2017 17:30:28 +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/spi/spidev.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index e6dc37fbea4e..846c54129744 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c @@ -106,8 +106,7 @@ spidev_sync(struct spidev_data *spidev, struct spi_message *message) spin_lock_irq(&spidev->spi_lock); spi = spidev->spi; spin_unlock_irq(&spidev->spi_lock); - - if (spi == NULL) + if (!spi) status = -ESHUTDOWN; else status = spi_sync(spi, message); @@ -218,7 +217,7 @@ static int spidev_message(struct spidev_data *spidev, spi_message_init(&msg); k_xfers = kcalloc(n_xfers, sizeof(*k_tmp), GFP_KERNEL); - if (k_xfers == NULL) + if (!k_xfers) return -ENOMEM; /* Construct spi_message, copying any tx data to bounce buffer. @@ -387,8 +386,7 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) spin_lock_irq(&spidev->spi_lock); spi = spi_dev_get(spidev->spi); spin_unlock_irq(&spidev->spi_lock); - - if (spi == NULL) + if (!spi) return -ESHUTDOWN; /* use the buffer lock here for triple duty: @@ -535,8 +533,7 @@ spidev_compat_ioc_message(struct file *filp, unsigned int cmd, spin_lock_irq(&spidev->spi_lock); spi = spi_dev_get(spidev->spi); spin_unlock_irq(&spidev->spi_lock); - - if (spi == NULL) + if (!spi) return -ESHUTDOWN; /* SPI_IOC_MESSAGE needs the buffer locked "normally" */ @@ -655,7 +652,7 @@ static int spidev_release(struct inode *inode, struct file *filp) spidev->speed_hz = spidev->spi->max_speed_hz; /* ... after we unbound from the underlying device? */ - dofree = (spidev->spi == NULL); + dofree = !spidev->spi; spin_unlock_irq(&spidev->spi_lock); if (dofree)