From patchwork Sun Sep 3 16:04:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13373281 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BCA28C71153 for ; Sun, 3 Sep 2023 16:04:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244300AbjICQEK (ORCPT ); Sun, 3 Sep 2023 12:04:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244264AbjICQEJ (ORCPT ); Sun, 3 Sep 2023 12:04:09 -0400 Received: from smtp.smtpout.orange.fr (smtp-19.smtpout.orange.fr [80.12.242.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3438101 for ; Sun, 3 Sep 2023 09:04:05 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id cpZyqw0SP3NA1cpZyqIn6j; Sun, 03 Sep 2023 18:04:03 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1693757043; bh=0Dvq01YC9MuzymMWpQIoP54YILXU0BzVCv3KM5F3VMM=; h=From:To:Cc:Subject:Date; b=Q4WMbVSZ36skZXQE9+/ctkGLhzX3XnlQK5RGd8F0vVgRmSZBmt50WwsrD+pHnRQ/H NmOZDTcUTuLjz7RgZ1zHg8Y3jqVtYi/GnOVZjkQyCrz8avQCXBPXDcGeHUyo1Gwl0I 4EAZ40iXSvLGXvJEM5yr/WX54Wqtj4SvzOMlW0uMjHYkr2K9xByRewFAtdBccQSPUx lqNrlhrt+JoMy82W3h6af0RuLi3C1tiONTUF8tqb+yiv1zw9hDClp7TJdoptG3RF2v TFawHU2RKKyB2nQmKUQwGcWSCyOVyvfsRztgC8Dk0ozTsIHE2hvY/yLRT/3d4qfXDz 3kGBGxcm3jg0w== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 03 Sep 2023 18:04:03 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Jiri Kosina , Benjamin Tissoires , Pascal Giard Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , Jiri Kosina , linux-input@vger.kernel.org Subject: [PATCH] HID: sony: Fix a potential memory leak in sony_probe() Date: Sun, 3 Sep 2023 18:04:00 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org If an error occurs after a successful usb_alloc_urb() call, usb_free_urb() should be called. Fixes: fb1a79a6b6e1 ("HID: sony: fix freeze when inserting ghlive ps3/wii dongles") Signed-off-by: Christophe JAILLET --- The NULL check is not needed, but I think that it is more informative written this way. --- drivers/hid/hid-sony.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index dd942061fd77..a02046a78b2d 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c @@ -2155,6 +2155,9 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) return ret; err: + if (sc->ghl_urb) + usb_free_urb(sc->ghl_urb); + hid_hw_stop(hdev); return ret; }