From patchwork Wed Sep 20 06:37:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9960933 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 C2B8560234 for ; Wed, 20 Sep 2017 06:38:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B676028E66 for ; Wed, 20 Sep 2017 06:38:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB4B628FAC; Wed, 20 Sep 2017 06:38:11 +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 6E1E328E66 for ; Wed, 20 Sep 2017 06:38:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751716AbdITGh5 (ORCPT ); Wed, 20 Sep 2017 02:37:57 -0400 Received: from mout.web.de ([212.227.15.4]:56812 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751688AbdITGhz (ORCPT ); Wed, 20 Sep 2017 02:37:55 -0400 Received: from [192.168.1.2] ([77.181.108.184]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MTxxp-1dm8ar13Dt-00QhFN; Wed, 20 Sep 2017 08:37:48 +0200 Subject: [PATCH 2/3] [media] pvrusb2-ioread: Delete an unnecessary check before kfree() in two functions From: SF Markus Elfring To: linux-media@vger.kernel.org, Mauro Carvalho Chehab , Mike Isely Cc: LKML , kernel-janitors@vger.kernel.org References: Message-ID: Date: Wed, 20 Sep 2017 08:37:47 +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: Content-Language: en-GB X-Provags-ID: V03:K0:nuCAU2zX5SSe2v7F/kO+fhJdI9f7i9b5AjxWnxMBF6kgChfW13D qnHA5iX3kg9xGDKcdFUej8kGCadONYugfEgMVVeGjNfouDYdQXnfV2YF0+SlfzDVWlFjJ9G uc2Ux8tshgsIMqh6rpkr0ChtPqPYr+v6Iw71U8eVR7+k/dkuPBsM3L9aIyjm1hMm7MbHP7C P88rx4AjReRv95Mn6pBuQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:LMGiZAZ5Qy8=:lZ6rqPvMLsYucePhe+nVib fA+5lg796fYYz40dRe+RY0X5fCW5bR64nPsrD0Vk7u1Yw/GiWwbLge4RtRkTfFLckfuwYLkLH H9PvM8GNlz1iy4wNSfbw5yvjX0rYlrUrijUvOqHyoyKrMbYdJAclUOqfKAUpopug9DIAIgguZ Gazq129RxfeJ1Obz6hU/5zIY15EVoZ17Rgqg3GeLigMSvCeBbwOY0xywHqnJ4XRKXud+lS6bU pPn3q56LJMU357u/J9AWWnZdXd+cSj+pivJkYdNA15SwGsvRzmWsJ/Iom1MZoV8CWDeN8gkhx YV51esxb0WsBDf+et/1fSbqUR+wKVJDaiFnS/Pb+5OjJVhRRVbRlD2wv6WkbSwuOGiqtoTRKB 1v2QuBeGMLgBrB6qfD/CETiBlsSzaAK98Ksj6KPJRlo/1trWEy8ADghBZgM6nxtkGZR1lDibQ BLm5XxamVIdfHVzXQ16TpuD9iUxgnJweQ7vPMpxlPQBjEe1gGDmxA3gq7caoSeU9WQPYJPpaq xgTTsmb1fBOOge+c0IO53h5iQ+WhXY2egInq7Y8IEstRz2aTbnWtN0/1AiSz0QBrP3wQry2wN 9s5oZdOyUfl7QA90EdYzuJ8YJDHGnJCVXjRwQyZNkRgBj/IxoITu4AtVAMRhjCyjjmTH1jmP6 TneU0M6XFErcw64Q9CNXmizLRf3RC0OOcvF48dkErFwpJrMGjeiX7VtxQELUnDuRrtS0mCa53 ZIniceM5Yz1yQ4JKxsw+2H4jmhdANyj5UFDXk7+DtABAcptUxR3/DYo0pdpySP0dFAD308ikk E3VPIzFql9+ExgX9x/Yj6n5oC9A1G4V4YXsKuy6x7BXM+tOU4Q= 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: Tue, 19 Sep 2017 22:12:49 +0200 The script "checkpatch.pl" pointed information out like the following. WARNING: kfree(NULL) is safe and this check is probably not required Thus fix the affected source code places. Signed-off-by: Markus Elfring --- drivers/media/usb/pvrusb2/pvrusb2-ioread.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/media/usb/pvrusb2/pvrusb2-ioread.c b/drivers/media/usb/pvrusb2/pvrusb2-ioread.c index 0218614ce988..4349f9b5f838 100644 --- a/drivers/media/usb/pvrusb2/pvrusb2-ioread.c +++ b/drivers/media/usb/pvrusb2/pvrusb2-ioread.c @@ -98,10 +98,8 @@ void pvr2_ioread_destroy(struct pvr2_ioread *cp) if (!cp) return; pvr2_ioread_done(cp); pvr2_trace(PVR2_TRACE_STRUCT,"pvr2_ioread_destroy id=%p",cp); - if (cp->sync_key_ptr) { - kfree(cp->sync_key_ptr); - cp->sync_key_ptr = NULL; - } + kfree(cp->sync_key_ptr); + cp->sync_key_ptr = NULL; kfree(cp); } @@ -117,10 +115,8 @@ void pvr2_ioread_set_sync_key(struct pvr2_ioread *cp, (!memcmp(sync_key_ptr,cp->sync_key_ptr,sync_key_len)))) return; if (sync_key_len != cp->sync_key_len) { - if (cp->sync_key_ptr) { - kfree(cp->sync_key_ptr); - cp->sync_key_ptr = NULL; - } + kfree(cp->sync_key_ptr); + cp->sync_key_ptr = NULL; cp->sync_key_len = 0; if (sync_key_len) { cp->sync_key_ptr = kmalloc(sync_key_len,GFP_KERNEL);