From patchwork Thu Aug 4 21:46:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bojan Prtvar X-Patchwork-Id: 1036892 X-Patchwork-Delegate: jikos@jikos.cz Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p74LlYa8019558 for ; Thu, 4 Aug 2011 21:47:34 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755463Ab1HDVrd (ORCPT ); Thu, 4 Aug 2011 17:47:33 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:65445 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755155Ab1HDVrc (ORCPT ); Thu, 4 Aug 2011 17:47:32 -0400 Received: by fxh19 with SMTP id 19so2147212fxh.19 for ; Thu, 04 Aug 2011 14:47:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; bh=u1A6k3KCF0yrxNjxggD8Z/I19yPfwAVWuULkFCuDlLk=; b=uyO8iog8vPtHDawgRpGdPQUNI0X444kYRRVfx08AxzXiAV9iPM4AiVDfFnqQ3ZxMgQ 55rMpgAMIFGhwsYZOtz+68KUub72i5PT13cED1CTqY4RSNocW1kDM9fQT8Ypnk76RteW NdV/qgZlbwXI4ernjhxxCcbpZ1+naAu9yKdrY= Received: by 10.223.20.143 with SMTP id f15mr1870255fab.49.1312494451098; Thu, 04 Aug 2011 14:47:31 -0700 (PDT) Received: from localhost.localdomain (109-93-49-6.dynamic.isp.telekom.rs [109.93.49.6]) by mx.google.com with ESMTPS id n27sm1519591faa.4.2011.08.04.14.47.29 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 04 Aug 2011 14:47:30 -0700 (PDT) From: Bojan Prtvar To: jkosina@suse.cz, julia@diku.dk Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Bojan Prtvar Subject: [PATCH 1/2 v2] HID: kfree() NULL pointer cleanup Date: Thu, 4 Aug 2011 23:46:48 +0200 Message-Id: <1312494408-15500-1-git-send-email-prtvar.b@gmail.com> X-Mailer: git-send-email 1.7.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Thu, 04 Aug 2011 21:47:34 +0000 (UTC) Checking for NULL pointers before kfree() is redundant. v2: No need for freeing pm in case when it's not allocated. Reported-by: Julia Lawall Signed-off-by: Bojan Prtvar --- drivers/hid/hid-prodikeys.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/hid/hid-prodikeys.c b/drivers/hid/hid-prodikeys.c index 158b389..f779009 100644 --- a/drivers/hid/hid-prodikeys.c +++ b/drivers/hid/hid-prodikeys.c @@ -816,7 +816,7 @@ static int pk_probe(struct hid_device *hdev, const struct hid_device_id *id) if (pm == NULL) { hid_err(hdev, "can't alloc descriptor\n"); ret = -ENOMEM; - goto err_free; + goto err_free_pk; } pm->pk = pk; @@ -849,10 +849,10 @@ static int pk_probe(struct hid_device *hdev, const struct hid_device_id *id) err_stop: hid_hw_stop(hdev); err_free: - if (pm != NULL) - kfree(pm); - + kfree(pm); +err_free_pk: kfree(pk); + return ret; }