From patchwork Thu Sep 21 19:25:20 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: 9964751 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 61AAC6020C for ; Thu, 21 Sep 2017 19:25:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 554112968B for ; Thu, 21 Sep 2017 19:25:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A0AA2968E; Thu, 21 Sep 2017 19:25:41 +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=unavailable 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 EDB042968B for ; Thu, 21 Sep 2017 19:25:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751748AbdIUTZ1 (ORCPT ); Thu, 21 Sep 2017 15:25:27 -0400 Received: from mout.web.de ([217.72.192.78]:58802 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751709AbdIUTZ0 (ORCPT ); Thu, 21 Sep 2017 15:25:26 -0400 Received: from [192.168.1.2] ([78.49.37.140]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0Ls95v-1dFIJK1ujn-013x0v; Thu, 21 Sep 2017 21:25:21 +0200 Subject: [PATCH 2/3] [media] uvcvideo: Adjust 14 checks for null pointers From: SF Markus Elfring To: linux-media@vger.kernel.org, Laurent Pinchart , Mauro Carvalho Chehab Cc: LKML , kernel-janitors@vger.kernel.org References: <20a8d1a5-45f1-2f98-e4b3-cfc24e9c04b0@users.sourceforge.net> Message-ID: <9f123108-2ef7-83ec-9981-280a24502771@users.sourceforge.net> Date: Thu, 21 Sep 2017 21:25:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20a8d1a5-45f1-2f98-e4b3-cfc24e9c04b0@users.sourceforge.net> Content-Language: en-GB X-Provags-ID: V03:K0:DlbXz/mw3DgZH66lr+tGxaxVabBD24lvTltU4m2ClsupXaqzXrl nfLsdKcmKGwCDnwjn87n4XdxBRHb9x8DJzue62i1Fju0s/NCv9xMi9lV9E7yDrzuI2fMFsn VvnHu/fL8A1hzMbd/iPC8UAYuQDp5JwIa8nTDO6kcBsGOQAs+wWtexkDJTEAlxrb/z3F5cE lsVpsMIOvSHWOuKlqHFNA== X-UI-Out-Filterresults: notjunk:1; V01:K0:hDpjOcsK7x4=:31i2rn+JM2NiyAVbCuz/CK zWuBoA1jXX4T6s7+CZpMt6HMdbMl/u//LLwyIhBEokK5xyPNWrn5FPlfs4AIhYvOTo78Myxaa JJNXNukd5+uWGyMZYH59rJGibBdAY/3iT4EEfSXfeJ1eYa0MjzxADzLBkTmWxW2mhaGYGwNcx OUBCijv+ySVXX9dOc4U9xjE6+w5sScqit7a0u+Q7q59vkvQ+1eOuOGZK4k414PM3CzyEe+tav xlJY2bUvLHKyoIlyjV+k450J4e8YoNMpetUN2vWOENmPiHql6uW4Pf1xGqNYgP5/5gLl+YqL2 L+8GsrVJdB+8EGwzIGsDm1NmZfBS7v7/uyD5rG7bwpTJj+nPhISgopEowXg5gAVh9p2zuGswS aUXfx+GFTfjo8PPf+O31bZQBSlRGLsj+4Oj4f/YqEmUWiNwNuhsHh3bOX3YyeNJqXsFZfK/ko 9V9Ww/JMV3mbNlIjwA2d73faTgJfJ2y40T/gLud8/uyS+owj7NwwsuN0vDJrX8zmt/nQxxub4 CcUMJLlz8nryKewxWcuywWxeh3UIJHR1DpZomdsh7ITp3zRXT1ypPTQkVy6IGwFysc9+KFloM VvY+mg0L460GUnAavxp7ebWchVc3jDD8EpMMAtKYRZ9kVeuDuLZUN8ih8nmYG8T6XifkH5r0j Jd4THdm5QnYoNJejBu/So0bqKGQLFP9V7RZj25w80l013oqKWL3adVVsGl3OBzF5w1zA9N6LC rJZDxWANxqPGITJcUIDQ890OmqFOZ2X0VFESZU6+opYYts1eipKlvUMMtntpL2ex7up/j2V1z QDePKho8lYLHsu3ugaqlf9gNaMjxFgxKyQ+SG6in2CodhPibSg= Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Thu, 21 Sep 2017 21:00:21 +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/media/usb/uvc/uvc_v4l2.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c index 6ec2b255c44a..184edf8a0885 100644 --- a/drivers/media/usb/uvc/uvc_v4l2.c +++ b/drivers/media/usb/uvc/uvc_v4l2.c @@ -41,7 +41,7 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain, int ret; map = kzalloc(sizeof *map, GFP_KERNEL); - if (map == NULL) + if (!map) return -ENOMEM; map->id = xmap->id; @@ -211,7 +211,7 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream, break; } - if (frame == NULL) { + if (!frame) { uvc_trace(UVC_TRACE_FORMAT, "Unsupported size %ux%u.\n", fmt->fmt.pix.width, fmt->fmt.pix.height); return -EINVAL; @@ -260,9 +260,9 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream, fmt->fmt.pix.colorspace = format->colorspace; fmt->fmt.pix.priv = 0; - if (uvc_format != NULL) + if (uvc_format) *uvc_format = format; - if (uvc_frame != NULL) + if (uvc_frame) *uvc_frame = frame; done: @@ -282,8 +282,7 @@ static int uvc_v4l2_get_format(struct uvc_streaming *stream, mutex_lock(&stream->mutex); format = stream->cur_format; frame = stream->cur_frame; - - if (format == NULL || frame == NULL) { + if (!format || !frame) { ret = -EINVAL; goto done; } @@ -499,7 +498,7 @@ static int uvc_v4l2_open(struct file *file) /* Create the device handle. */ handle = kzalloc(sizeof *handle, GFP_KERNEL); - if (handle == NULL) { + if (!handle) { usb_autopm_put_interface(stream->dev->intf); return -ENOMEM; } @@ -811,7 +810,7 @@ static int uvc_ioctl_enum_input(struct file *file, void *fh, u32 index = input->index; int pin = 0; - if (selector == NULL || + if (!selector || (chain->dev->quirks & UVC_QUIRK_IGNORE_SELECTOR_UNIT)) { if (index != 0) return -EINVAL; @@ -830,7 +829,7 @@ static int uvc_ioctl_enum_input(struct file *file, void *fh, } } - if (iterm == NULL || iterm->id != pin) + if (!iterm || iterm->id != pin) return -EINVAL; memset(input, 0, sizeof(*input)); @@ -849,7 +848,7 @@ static int uvc_ioctl_g_input(struct file *file, void *fh, unsigned int *input) int ret; u8 i; - if (chain->selector == NULL || + if (!chain->selector || (chain->dev->quirks & UVC_QUIRK_IGNORE_SELECTOR_UNIT)) { *input = 0; return 0; @@ -876,7 +875,7 @@ static int uvc_ioctl_s_input(struct file *file, void *fh, unsigned int input) if (ret < 0) return ret; - if (chain->selector == NULL || + if (!chain->selector || (chain->dev->quirks & UVC_QUIRK_IGNORE_SELECTOR_UNIT)) { if (input) return -EINVAL; @@ -1160,7 +1159,7 @@ static int uvc_ioctl_enum_framesizes(struct file *file, void *fh, break; } } - if (format == NULL) + if (!format) return -EINVAL; if (fsize->index >= format->nframes) @@ -1189,7 +1188,7 @@ static int uvc_ioctl_enum_frameintervals(struct file *file, void *fh, break; } } - if (format == NULL) + if (!format) return -EINVAL; for (i = 0; i < format->nframes; i++) { @@ -1199,7 +1198,7 @@ static int uvc_ioctl_enum_frameintervals(struct file *file, void *fh, break; } } - if (frame == NULL) + if (!frame) return -EINVAL; if (frame->bFrameIntervalType) {