Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4883286ybv; Mon, 17 Feb 2020 07:45:28 -0800 (PST) X-Google-Smtp-Source: APXvYqyu+irP2+kHlgOgBLcNgv2dR8p5Q6uJJyXHUM7RmKqji6XwdkAR7QsZI3fNHYWyUzfvzEbC X-Received: by 2002:a05:6830:1e37:: with SMTP id t23mr13025877otr.16.1581954328523; Mon, 17 Feb 2020 07:45:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581954328; cv=none; d=google.com; s=arc-20160816; b=mDDV2qLUreYejOJ4axS/b5rlo+otzHjpHrMvDqTHX25AMj0J2MomnrHYN6n3+5S1oA naGyyxGnVq7XhMAIk5qsFOV2u/rpbPW9yckn/fQ+mrRkHvenZ3AIWFn88B2C9XT6I2GQ XVPo7JY24h6a4YIm5pdiDpYWWN67UB95/2jV7rM+Dy0fYfZngnPGLmeOr3kqEKwiJ10/ YISh2Ri8XF2fFPpFRtAkvQy542T9kasEug8qX2bJB+IfvK0vGBYwPL/F5n4MDCORuIM6 jQ2mAhaMDBPMd70uC8Nhna3VS8hm+mpReusWT1GxmeftwGjE9lvOXxmS7e73VI4eQoDq 0Ikg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:to:from:subject:dkim-signature; bh=P5DWN49D92TYsuLESpqd7fS0a6DhOWs1cg95OmyVKFk=; b=TgJOo6piF01WH1sJqifiZRa8TUhixN1Cpfl6vf2sZ19ydgDiyEZjvO1lFWdlovzgcX X7vH1Ws0O/gBhQZGCiotosO5cddrVG3Z8l2t+QTyVOJK+pP3PzPl+TGDaI4IZAQyznaL oNUfKXgu8v/8gkqg8mlClWChgF9NxuheaUHamGlHGV90SCZ3TTK9+hTUPoA1kxSFClS9 iyJ3n0Nb4kai/8jXuBhoXjuZOXK60qwhoJ4fPZRcH32Xii7p2Ge/ZqnVITu/10ntPoN6 bLloLq4X6wE//QZJYIP/Lv63nfVh/QABsF8kesPEQ51xqtQsDu1Q+3c8vc4SWW6+xFs0 8skw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@hanno.de header.s=default1911 header.b=D2lB239x; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z15si6167294oih.41.2020.02.17.07.45.16; Mon, 17 Feb 2020 07:45:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@hanno.de header.s=default1911 header.b=D2lB239x; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729398AbgBQPo6 (ORCPT + 99 others); Mon, 17 Feb 2020 10:44:58 -0500 Received: from www149.your-server.de ([78.47.15.70]:59968 "EHLO www149.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726528AbgBQPo5 (ORCPT ); Mon, 17 Feb 2020 10:44:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hanno.de; s=default1911; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:References:To:From:Subject:Sender:Reply-To:Cc: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=P5DWN49D92TYsuLESpqd7fS0a6DhOWs1cg95OmyVKFk=; b=D2lB239xIof0jQmbs+GSHfSNbe CMoDIL7ln0iQ7lJIMnWDjDJmJlzg8vxPAO8N1/n6EqKTVSx1FRDIB9SF5OSc3lFkpPIb3XVMywhIk 2J6E9UFfXCDohvAIJdetYWPzVAAdrZlaVrsNVB0YunW94QPcZdLFyLjOR8fITnEP8W1YsRGFNj0sc DdO/Y3OJRNQxo9P7UvID3Ty9gR8ttOXTto6cDLlsFLmLNdz0wgucfiNd4yUmmcVK5pg+9BToxclTF HrdOY63IXqFjuVYPbhucOAn0L6r1UwTtJ7yB3UL0EEmFSraFoiRwtRnlDbQMvhGbuQnIdH8quq5S1 Zr3xR+bQ==; Received: from sslproxy06.your-server.de ([78.46.172.3]) by www149.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1j3iHS-0004ld-Q4; Mon, 17 Feb 2020 16:25:54 +0100 Received: from [62.96.7.134] (helo=[10.1.0.41]) by sslproxy06.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j3iHS-00080q-MV; Mon, 17 Feb 2020 16:25:54 +0100 Subject: [PATCH 1/3] HID: hid-bigbenff: fix general protection fault caused by double kfree From: Hanno Zulla To: Jiri Kosina , Benjamin Tissoires , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org References: Message-ID: <798ec119-ce24-e1e3-17c9-b6018b04d75f@hanno.de> Date: Mon, 17 Feb 2020 16:25:54 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: abos@hanno.de X-Virus-Scanned: Clear (ClamAV 0.102.1/25726/Mon Feb 17 15:01:07 2020) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org HID: hid-bigbenff: fix general protection fault caused by double kfree The struct *bigben was allocated via devm_kzalloc() and then used as a parameter in input_ff_create_memless(). This caused a double kfree during removal of the device, since both the managed resource API and ml_ff_destroy() in drivers/input/ff-memless.c would call kfree() on it. Signed-off-by: Hanno Zulla --- drivers/hid/hid-bigbenff.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-bigbenff.c b/drivers/hid/hid-bigbenff.c index 3f6abd190df4..f7e85bacb688 100644 --- a/drivers/hid/hid-bigbenff.c +++ b/drivers/hid/hid-bigbenff.c @@ -220,10 +220,16 @@ static void bigben_worker(struct work_struct *work) static int hid_bigben_play_effect(struct input_dev *dev, void *data, struct ff_effect *effect) { - struct bigben_device *bigben = data; + struct hid_device *hid = input_get_drvdata(dev); + struct bigben_device *bigben = hid_get_drvdata(hid); u8 right_motor_on; u8 left_motor_force; + if (!bigben) { + hid_err(hid, "no device data\n"); + return 0; + } + if (effect->type != FF_RUMBLE) return 0; @@ -341,7 +347,7 @@ static int bigben_probe(struct hid_device *hid, INIT_WORK(&bigben->worker, bigben_worker); - error = input_ff_create_memless(hidinput->input, bigben, + error = input_ff_create_memless(hidinput->input, NULL, hid_bigben_play_effect); if (error) return error; -- 2.20.1