From patchwork Sat Jan 22 09:48:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongliang Mu X-Patchwork-Id: 12720698 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 3B94AC433F5 for ; Sat, 22 Jan 2022 09:59:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232089AbiAVJ7Y (ORCPT ); Sat, 22 Jan 2022 04:59:24 -0500 Received: from hust.edu.cn ([202.114.0.240]:31741 "EHLO hust.edu.cn" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S229773AbiAVJ7Y (ORCPT ); Sat, 22 Jan 2022 04:59:24 -0500 X-Greylist: delayed 607 seconds by postgrey-1.27 at vger.kernel.org; Sat, 22 Jan 2022 04:59:23 EST Received: from localhost.localdomain ([172.16.0.254]) (user=dzm91@hust.edu.cn mech=LOGIN bits=0) by mx1.hust.edu.cn with ESMTP id 20M9mYeN013481-20M9mYeQ013481 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Sat, 22 Jan 2022 17:48:39 +0800 From: Dongliang Mu To: Jiri Kosina , Benjamin Tissoires , Salah Triki Cc: Dongliang Mu , syzkaller , Jiri Kosina , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] hid: elo: fix memory leak in elo_probe Date: Sat, 22 Jan 2022 17:48:26 +0800 Message-Id: <20220122094827.684542-1-dzm91@hust.edu.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-FEAS-AUTH-USER: dzm91@hust.edu.cn Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Dongliang Mu When hid_parse in elo_probe fails, it forgets to call usb_put_dev to decrease the refcount. Fix this by adding usb_put_dev in the error handling code of elo_probe Fixes: fbf42729d0e9 ("HID: elo: update the reference count of the usb device structure") Reported-by: syzkaller Signed-off-by: Dongliang Mu --- drivers/hid/hid-elo.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/hid/hid-elo.c b/drivers/hid/hid-elo.c index 8e960d7b233b..9b42b0cdeef0 100644 --- a/drivers/hid/hid-elo.c +++ b/drivers/hid/hid-elo.c @@ -262,6 +262,7 @@ static int elo_probe(struct hid_device *hdev, const struct hid_device_id *id) return 0; err_free: + usb_put_dev(udev); kfree(priv); return ret; }