From patchwork Tue Feb 7 19:50:24 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: 9560993 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 4FB4260236 for ; Tue, 7 Feb 2017 19:51:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41E9F2847C for ; Tue, 7 Feb 2017 19:51:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3530828487; Tue, 7 Feb 2017 19:51:37 +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 136E92847C for ; Tue, 7 Feb 2017 19:51:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932255AbdBGTuv (ORCPT ); Tue, 7 Feb 2017 14:50:51 -0500 Received: from mout.web.de ([212.227.17.11]:52013 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932246AbdBGTuu (ORCPT ); Tue, 7 Feb 2017 14:50:50 -0500 Received: from [192.168.1.2] ([78.49.4.3]) by smtp.web.de (mrweb103 [213.165.67.124]) with ESMTPSA (Nemesis) id 0M413W-1cJFWV0IZ0-00rXVX; Tue, 07 Feb 2017 20:50:25 +0100 Subject: [PATCH 08/18] HID: Adjust five checks for null pointers To: linux-input@vger.kernel.org, Benjamin Tissoires , =?UTF-8?Q?Bruno_Pr=c3=a9mont?= , Jiri Kosina References: Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: <8dbffcc9-34e2-5e1d-e4f5-342786f91c53@users.sourceforge.net> Date: Tue, 7 Feb 2017 20:50:24 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: X-Provags-ID: V03:K0:dZhjlSbL+YzelAPHFZw3nDwN275xaxlhxfZUeZMV90iMkhmufjt JLjd09FJrWP90l96Q/3drxV5Ke/Zq/JejD327Xs7eQS2Ota+bPO8Md8NnWUdRTdMZXmaTu+ ZsnXClDj8s2k3xrb8cn8AZpjLLCyiMVqBXhPJHZ5CXp7fSGjUvoa/hWUrsaYXvEOGHoyfY5 +sViXMHMATLuASVxKS/lg== X-UI-Out-Filterresults: notjunk:1; V01:K0:VoPkya9b3Y8=:Cg6XglH+YEFu4YytYomFZi OmgyO8WwYqKSV3EzouKxNpHWa5L/o9EUQIQjyQ/vRaEJtEJheqKOe7pQsXIUy2hmCY2uXPjlT HHbCpX/NiRd8XXJqA0mlaQnU/mG9UA7opiDt3l0ZitZ1lcZnXPNsJhc1PGTaTD26lJH0lqwfS fvIYteUKxY+2D/O2VCOMS4XrNmblDjPsylagPXmJpMUq7czfmGk1yC4N4F7aYjhutKuaPcllX s1sqsIsMq1aUPtW3+28Cp9pIaatk+tafuDVizUM8SW85Qa3UyItNYFZixX5jhu44AtK43PkF7 NVkDCNsqGmgqlS14iJ4FNQpJ7ZgHbifqgrOvb15MaIsbqJB4fLMGk3EUR7w0qREmr8GFFm0MP Afp1a2q/+RuPV+318fbdVg32ZFMrGqwu7buQgQbbcqDnWBEJNibREoyCcQjCUFECBaVBoQkJ0 QmBKguPSYPQ8icq2u01up6l4xua7xo+UE4kP2KqYFueuEgaj8xL82uMMnkOWjMulKweYGUHIl SOWznf2gAMs9oW8lgqQCsPKYiuYwFJsHQdbCxXcy8oouVzDKV0vx6tX/KmB+lJ0bLeFCg3uEH rCB/qVsrki10IX3SpOy6Rz3jly6Ac9pT3UH+VGivT+iDtXGeTvqvrcSm/3HC/Kjpxt+1g48D2 5bgYCoLVUUyt5f6edloLQwk+C/SrY4NTLIRJo9U4KdYRyBXSm/JgzMGiXTp1Mlv+flOpe1MYs +2DwseAAjmhIJeHRo6b5PTRjNWBa9LSutCMU2yBst/wU2ZoVzfxD/Ey2+7XTZNN/MxfevsgOd 6/d8jhY Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Tue, 7 Feb 2017 19:15:21 +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 affected source code places. Signed-off-by: Markus Elfring --- drivers/hid/hid-core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 1f75c1c022f0..f4ea3590954c 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -959,7 +959,7 @@ int hid_open_report(struct hid_device *device) size = device->dev_rsize; buf = kmemdup(start, size, GFP_KERNEL); - if (buf == NULL) + if (!buf) return -ENOMEM; if (device->driver->report_fixup) @@ -969,7 +969,7 @@ int hid_open_report(struct hid_device *device) start = kmemdup(start, size, GFP_KERNEL); kfree(buf); - if (start == NULL) + if (!start) return -ENOMEM; device->rdesc = start; @@ -1414,7 +1414,7 @@ static struct hid_report *hid_get_report(struct hid_report_enum *report_enum, n = *data; report = report_enum->report_id_hash[n]; - if (report == NULL) + if (!report) dbg_hid("undefined report_id %u received\n", n); return report; @@ -2222,7 +2222,7 @@ static int hid_device_probe(struct device *dev) if (!hdev->driver) { id = hid_match_device(hdev, hdrv); - if (id == NULL) { + if (!id) { ret = -ENODEV; goto unlock; } @@ -2719,7 +2719,7 @@ struct hid_device *hid_allocate_device(void) int ret = -ENOMEM; hdev = kzalloc(sizeof(*hdev), GFP_KERNEL); - if (hdev == NULL) + if (!hdev) return ERR_PTR(ret); device_initialize(&hdev->dev);