From patchwork Fri Apr 22 16:17:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 12823726 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 BC056C433EF for ; Fri, 22 Apr 2022 16:17:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377448AbiDVQUS (ORCPT ); Fri, 22 Apr 2022 12:20:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351477AbiDVQUR (ORCPT ); Fri, 22 Apr 2022 12:20:17 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D59F35C861; Fri, 22 Apr 2022 09:17:23 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id w4so11734283wrg.12; Fri, 22 Apr 2022 09:17:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tsTMShhOunXxsSfDe94cDR9nLWccacVm3HSfzZBOByg=; b=nKvgMY2IWH2PEHEZ+cl7OGmxw5xlhk3x5mrd/sdrjE03WJ0A4/iMINxWKaze7/4z1D EaZgcXfpsI07TuM7B7xC1eAjB4SiZR6YP8B5CaRzMStCvqaY2VNc7Otw68D+6PvDTYIb SW86CV3hpfJUOYU4waQJ4eOzLLoqdiz/BXlLtY9AstrlCmKu1LxEYJ4mkGe0ezZs+Wih AMRs6V6OMn0Jq8aCiE91ildQzfNoAbTBifdfnxJ3CYqmqb8ERjQ/JufqKQJpRCyOw2ih +1VAm6TrSldcATLGDX+RMHq5ZAoCbQlRcnvqppWUNLDjsyQtn3QYYfGo+fbx4dMXkLIf dWhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tsTMShhOunXxsSfDe94cDR9nLWccacVm3HSfzZBOByg=; b=v/yMXmQRruIZPwpdLGCh0aeqxfPmVM1NHfeQazEoddEAgmI4rRRY+V/hTUvXsSucBg 7CwviGNqa7RxBQUn5kLxFy69kWtPtyVUJxf5B9VoNCdEUUcK3/YosQJB0pEbYZyL427f kVR+AerdSue9VZal7mUPEzilVxP/20E4J+ar7TnGXsld75r27qA5PFUuB7hd7FXx+Ukl uDu0E+8f7DlHrqPGpae4yrqqVPXkKopN12Ds8x7+S1azeRoUcqEJ2V8DXVAm59C8JamE uPLPiqKKggYwbwS7ogvRuD729A+E3n/OZAgXrM+Efv/fdEtt2iTeapWnDduxYRkg9Zyc oMug== X-Gm-Message-State: AOAM532fBGFWxXGIMWT88z4XomMjsQejEewnKMFBhwid52wnI/9kn6Bm J+FF/N71ok7GaXmT25+3r/I= X-Google-Smtp-Source: ABdhPJx/muX49NvkIJ81aOJD11FvjLIeaod4BAQfzC8mIBwV/3b+XFa47AyKcGsqSoyl5DnvnisimQ== X-Received: by 2002:a05:6000:16c1:b0:20a:b1c5:d7db with SMTP id h1-20020a05600016c100b0020ab1c5d7dbmr4457798wrf.64.1650644242311; Fri, 22 Apr 2022 09:17:22 -0700 (PDT) Received: from localhost.localdomain ([94.73.37.128]) by smtp.gmail.com with ESMTPSA id 20-20020a05600c22d400b0038c8dbdc1a3sm1927029wmg.38.2022.04.22.09.17.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 09:17:22 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: hadess@hadess.net Cc: hdegoede@redhat.com, dmitry.torokhov@gmail.com, rydberg@bitmath.org, lains@riseup.net, jikos@kernel.org, benjamin.tissoires@redhat.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?b?Sm9z?= =?utf-8?b?w6kgRXhww7NzaXRv?= Subject: [PATCH 1/3] Input: goodix - Fix double free on managed resource Date: Fri, 22 Apr 2022 18:17:07 +0200 Message-Id: <20220422161709.30198-1-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org As described in the documentation for devm_input_allocate_device(): Managed input devices do not need to be explicitly unregistered or freed as it will be done automatically when owner device unbinds from its driver (or binding fails). However this driver was explicitly freeing the input device. Remove the calls to input_free_device() to avoid a possible double free error. Fixes: 5ede7f0cfb93f ("Input: goodix - add pen support") Signed-off-by: José Expósito --- drivers/input/touchscreen/goodix.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c index 752e8ba4fecb..61eb69f3a259 100644 --- a/drivers/input/touchscreen/goodix.c +++ b/drivers/input/touchscreen/goodix.c @@ -308,10 +308,8 @@ static struct input_dev *goodix_create_pen_input(struct goodix_ts_data *ts) return NULL; input_alloc_absinfo(input); - if (!input->absinfo) { - input_free_device(input); + if (!input->absinfo) return NULL; - } input->absinfo[ABS_X] = ts->input_dev->absinfo[ABS_MT_POSITION_X]; input->absinfo[ABS_Y] = ts->input_dev->absinfo[ABS_MT_POSITION_Y]; @@ -340,10 +338,8 @@ static struct input_dev *goodix_create_pen_input(struct goodix_ts_data *ts) input->id.product = 0x1001; input->id.version = ts->version; - if (input_register_device(input) != 0) { - input_free_device(input); + if (input_register_device(input) != 0) return NULL; - } return input; } From patchwork Fri Apr 22 16:17:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 12823727 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 3BF47C433EF for ; Fri, 22 Apr 2022 16:17:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378457AbiDVQUZ (ORCPT ); Fri, 22 Apr 2022 12:20:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378340AbiDVQUX (ORCPT ); Fri, 22 Apr 2022 12:20:23 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28B8D5DE60; Fri, 22 Apr 2022 09:17:29 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id 17-20020a05600c021100b00393a19f8f98so2631510wmi.4; Fri, 22 Apr 2022 09:17:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rIncxmhDUFubuTPIbfUUmhnyD3x3kFknV3aR1PwAHSU=; b=quLHBak67ilJ7XMk5cWh59WRxF7B6IHMYoaeosRq419Hmg1wM8lhRiwbfpOVrbNYn0 WMiZVqrmL8JCp034/D4u5h7itqTpq0O4jXNIdvsTFMbyOtwHh4lYHysD866BVOkLQ5La 17cwTCAS0a+ifbRTJrZnJi2TtYjBCXluT8noIq65EDNP302VMEHrYyaDNy7iPltS3C0h QYNRlQKMAtzMPfFSW+nSUN85N9Kw4j2ZxezhZyV11lMxgWoCm43IPGBT7ItE409Sj4vu aYhAWHrVL7/bzht5d/TY0KaOk4EPEtGuEBwfy6RafkhzBmxZxXLzCcSZMbhMAoTzf81O u6fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rIncxmhDUFubuTPIbfUUmhnyD3x3kFknV3aR1PwAHSU=; b=GGzAwcTyLWQaN3PM6ThV9gYlgx0GlbgiBbl+pZDmoyZXY+6lXrs53KP7RrVjQEoyCM CAmwVTzSSQFgJcAHALCJSv8xqK17fGElW+duCHqZtWII0LQ2iqvznx+cLf+a+zJb4Non UoxY01iZYfU5X5kvDxd5EWBtpeYb/K1iU0jz4VY0dXEZci7STcDUcWL1PJLbhlSfxrj5 yjUaUzDrSQfKx5u2gVjaqoq2a9qeNCpDuDqFEAuRXke9qHF017zUqClVsTgLKonhqkVh tFzZ3rwUxeRsYDsnqHfqlQr0YjtzOxNhCahOEb4Yv17SoqCURhCystGLsS4mWVSnod6o g5Iw== X-Gm-Message-State: AOAM533PkkFsOJoHFRshNL3aEV43t/HTzlMOy8akspaUEreoByeMl5hH ZLq1PF2ztQo0rxJ7LTCZ3qdDNgwF7exqCA== X-Google-Smtp-Source: ABdhPJy7KeEOprOPRKSsTs4cY5EYO9wXLB8zfkM0gOMvToggZOXNlBAOI4qobW464wC53PUnuMbrgA== X-Received: by 2002:a05:600c:350f:b0:392:90d0:6b12 with SMTP id h15-20020a05600c350f00b0039290d06b12mr4851402wmq.180.1650644247720; Fri, 22 Apr 2022 09:17:27 -0700 (PDT) Received: from localhost.localdomain ([94.73.37.128]) by smtp.gmail.com with ESMTPSA id 20-20020a05600c22d400b0038c8dbdc1a3sm1927029wmg.38.2022.04.22.09.17.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 09:17:27 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: hadess@hadess.net Cc: hdegoede@redhat.com, dmitry.torokhov@gmail.com, rydberg@bitmath.org, lains@riseup.net, jikos@kernel.org, benjamin.tissoires@redhat.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?b?Sm9z?= =?utf-8?b?w6kgRXhww7NzaXRv?= Subject: [PATCH 2/3] HID: logitech-hidpp: Fix double free on managed resource Date: Fri, 22 Apr 2022 18:17:08 +0200 Message-Id: <20220422161709.30198-2-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220422161709.30198-1-jose.exposito89@gmail.com> References: <20220422161709.30198-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org As described in the documentation for devm_input_allocate_device(): Managed input devices do not need to be explicitly unregistered or freed as it will be done automatically when owner device unbinds from its driver (or binding fails). However this driver was explicitly freeing the input device, allocated using devm_input_allocate_device() through hidpp_allocate_input(). Remove the call to input_free_device() to avoid a possible double free error. Fixes: c39e3d5fc9dd3 ("HID: logitech-hidpp: late bind the input device on wireless connection") Signed-off-by: José Expósito --- drivers/hid/hid-logitech-hidpp.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index 81de88ab2ecc..9c00a781ab57 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -3957,11 +3957,7 @@ static void hidpp_connect_event(struct hidpp_device *hidpp) } hidpp_populate_input(hidpp, input); - - ret = input_register_device(input); - if (ret) - input_free_device(input); - + input_register_device(input); hidpp->delayed_input = input; } From patchwork Fri Apr 22 16:17:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 12823728 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 DB6B4C433EF for ; Fri, 22 Apr 2022 16:17:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378340AbiDVQUd (ORCPT ); Fri, 22 Apr 2022 12:20:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378994AbiDVQUc (ORCPT ); Fri, 22 Apr 2022 12:20:32 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3D1F5C861; Fri, 22 Apr 2022 09:17:38 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id k22so11784838wrd.2; Fri, 22 Apr 2022 09:17:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aqaDmVSTH8kRIVx2Jc7UCmC/D+1NcV2YaY4UF+KoQrE=; b=LBRrPEsh5v4Ua+CSf7zr4C62y//TkfzRqpV3PBZJRBv4CRQdOGCoTEQaKNDTp+sLlk lKwrtnBRF8oP6xhAtavb18l0DVnUYCPeACgbWDZx7ivGRtLyfMq63htBTs8V6XJX9zo7 AUwTPdl5h8ZwGIys2HQAsC4um9xLK67DhwofOQGd6/G5h9srgZZ9vF+iSSU0fRt058wc uI9jgBIs8BGFZbWPFwO+C8b/ibDYwKOa4px0WctiWv4BaDqzrhLP1fi8c/FPArFrGC2N PO5BlTdOTweSO33q/9Ajn3Uubn8oS3UaG4Ob1fTdtOp+s9lw6TySzSzis7YMqnpt/YIb PRLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aqaDmVSTH8kRIVx2Jc7UCmC/D+1NcV2YaY4UF+KoQrE=; b=3XJX8DdtSsshOqyqjf5Y0C0Zyj/AzUtjDYY2Bew0d8iCn7FEBvICEDxKvDFPxwgbf6 UaysJ0E6ltDCKfxkvpXZMOtcAkkKmIlG+xkc8iWHDp+wkj8Jb/x4xdYKF3J+ZIg7KhKD X2nVv/fdP/jKV2lAg0sCJ7u1ksCWbnVmKXFG0hWiow265UfpGHKnrvhLSd7KVzwBunZy mFBtE2EHNw50dMG/tqiKBQBbj581rRd6j8V++ySbIN/rnNnfzcrTdaO0/ps7uMDZg4TE pkbM8L3vUgJkOuu7YrZrNIVf4DjO8A0NG6x72hlJptN5HGmShR/bKTdyYnEdaTFfdg3w zhTQ== X-Gm-Message-State: AOAM532F8ACcty0bemC1atgMP3gZiTs9m5moyPYfgyI+o9cFwDxCfDAr Z2PtFOF110FbnuD/gd8cTQE= X-Google-Smtp-Source: ABdhPJy8A+5MLmvgrVf6CaFzLQbY516nLLbku9rWWNatXqiOrdjiHJhHtgZ0ZGYa/KZ/OmNHmanEBg== X-Received: by 2002:adf:da49:0:b0:204:1548:2a58 with SMTP id r9-20020adfda49000000b0020415482a58mr4400090wrl.664.1650644257315; Fri, 22 Apr 2022 09:17:37 -0700 (PDT) Received: from localhost.localdomain ([94.73.37.128]) by smtp.gmail.com with ESMTPSA id 20-20020a05600c22d400b0038c8dbdc1a3sm1927029wmg.38.2022.04.22.09.17.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 09:17:37 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: hadess@hadess.net Cc: hdegoede@redhat.com, dmitry.torokhov@gmail.com, rydberg@bitmath.org, lains@riseup.net, jikos@kernel.org, benjamin.tissoires@redhat.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?b?Sm9z?= =?utf-8?b?w6kgRXhww7NzaXRv?= Subject: [PATCH 3/3] HID: wacom: Fix double free on managed resource Date: Fri, 22 Apr 2022 18:17:09 +0200 Message-Id: <20220422161709.30198-3-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220422161709.30198-1-jose.exposito89@gmail.com> References: <20220422161709.30198-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org As described in the documentation for devm_input_allocate_device(): Managed input devices do not need to be explicitly unregistered or freed as it will be done automatically when owner device unbinds from its driver (or binding fails). However this driver was explicitly freeing the input device, allocated using devm_input_allocate_device() through wacom_allocate_input(). Remove the calls to input_free_device() to avoid a possible double free error. Fixes: d2d13f18aaa51 ("Input: wacom - create a separate input device for pads") Signed-off-by: José Expósito --- drivers/hid/wacom_sys.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index 066c567dbaa2..164c0f7cb796 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c @@ -2098,7 +2098,6 @@ static int wacom_register_inputs(struct wacom *wacom) error = wacom_setup_pen_input_capabilities(pen_input_dev, wacom_wac); if (error) { /* no pen in use on this interface */ - input_free_device(pen_input_dev); wacom_wac->pen_input = NULL; pen_input_dev = NULL; } else { @@ -2110,7 +2109,6 @@ static int wacom_register_inputs(struct wacom *wacom) error = wacom_setup_touch_input_capabilities(touch_input_dev, wacom_wac); if (error) { /* no touch in use on this interface */ - input_free_device(touch_input_dev); wacom_wac->touch_input = NULL; touch_input_dev = NULL; } else { @@ -2122,7 +2120,6 @@ static int wacom_register_inputs(struct wacom *wacom) error = wacom_setup_pad_input_capabilities(pad_input_dev, wacom_wac); if (error) { /* no pad in use on this interface */ - input_free_device(pad_input_dev); wacom_wac->pad_input = NULL; pad_input_dev = NULL; } else {