Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2534163yba; Mon, 6 May 2019 07:37:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzQyooDV8qiFiLyLekDhet63pG4C1fJCDwy2Jwhwb/gaVp0AuGdsJjhdLfdjP3pd7/8OJUZ X-Received: by 2002:a17:902:29a7:: with SMTP id h36mr32612107plb.319.1557153453538; Mon, 06 May 2019 07:37:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557153453; cv=none; d=google.com; s=arc-20160816; b=idxmFCTiCl0E11tbKPyL6AzJ9+L389pQ6BuCimd7OYe3DpYFkyK9/tVra27DwW9S+D aYPg2GaOwmn//Oy3aPpcY+uKfB6Mk90RcjDrDIVZ5ZiJrCq7x2vP6LaZEAMtLC8Zy4ve GVp4Ul/YHplskRQQkRhlGrAldowF17z4R/uEDdyHp4B2J9D9HLZTrtK6GbN0Di5nuOLC UwbE68xxPVn9rfpf/vzSlP5HTaLxCXqB+ovjtO0UuonJxaOrbahoqsqps77cqSHnctHo T4SP4/9Rx/SdErJ1aySKnRwGVg4r+SP5/KuFCLMyY5+IFZgUw2LfeCX1Igqn/GDrPnB6 McuA== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=e7LmstokxSodGZIEZ6QG0GsLTKnLD0RbCre9UaosEwg=; b=wv0oLT6M5Yspaylsbmhp/tPh+z+1mPDxTzFXrSUmhBGQAuzoBBiZ3pVau8F+bmgcEs JsWhJa9wbO9Af7WTt3XGCX72aXrYFG7cyHURRpeKWqSXOMHwcORe9/EGY2D2UWB748D2 9QvAD0iHrVE3T5QwA3F6HaEB4T0Lf0K4EnHrxljYlVlw7ZJavsGOWoC7lJV/XV+2V0c4 ClIl+i3fcOI3fnYaBzgbQ3MSVz/ZEyoUwYnAtWz5xJ+8w/ydvix0Dnbjr0uJIOf4jls1 pWmd4y7//nlzfgyz5BeNZcxvWzHuwvaEmfAQPHJL+tlIM74/fr3BCORKzPj7veTiXyHA RvjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nOj8bBXf; 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 e15si14556703pgm.377.2019.05.06.07.37.11; Mon, 06 May 2019 07:37:33 -0700 (PDT) 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=pass header.i=@kernel.org header.s=default header.b=nOj8bBXf; 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 S1726962AbfEFOff (ORCPT + 99 others); Mon, 6 May 2019 10:35:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:55628 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726954AbfEFOfc (ORCPT ); Mon, 6 May 2019 10:35:32 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F1171214AE; Mon, 6 May 2019 14:35:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557153331; bh=/CtsiC3QKIiq+eFj1WiGdmRM56VbB/uKlEKnvHHzNXI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nOj8bBXfKPGT7Mwtry1ykmmQJcDceyZeIzNZ0bPxKTcYFKYskkRl8Y5xH42re7p7b Iejjsx5KX2JDpcHk1KB2oG5tRi9l1jKIuBSr6C8uoBlHlaoIZQrLDB0EWpqOibEiFc 1K6+h977BhlOLWQ3ygPrk44MBRh63ukn7w44Be1s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kangjie Lu , Jiri Kosina , "Sasha Levin (Microsoft)" Subject: [PATCH 5.0 027/122] HID: logitech: check the return value of create_singlethread_workqueue Date: Mon, 6 May 2019 16:31:25 +0200 Message-Id: <20190506143057.185665784@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190506143054.670334917@linuxfoundation.org> References: <20190506143054.670334917@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 6c44b15e1c9076d925d5236ddadf1318b0a25ce2 ] create_singlethread_workqueue may fail and return NULL. The fix checks if it is NULL to avoid NULL pointer dereference. Also, the fix moves the call of create_singlethread_workqueue earlier to avoid resource-release issues. Signed-off-by: Kangjie Lu Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin (Microsoft) --- drivers/hid/hid-logitech-hidpp.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index f040c8a7f9a9..199cc256e9d9 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -2111,6 +2111,13 @@ static int hidpp_ff_init(struct hidpp_device *hidpp, u8 feature_index) kfree(data); return -ENOMEM; } + data->wq = create_singlethread_workqueue("hidpp-ff-sendqueue"); + if (!data->wq) { + kfree(data->effect_ids); + kfree(data); + return -ENOMEM; + } + data->hidpp = hidpp; data->feature_index = feature_index; data->version = version; @@ -2155,7 +2162,6 @@ static int hidpp_ff_init(struct hidpp_device *hidpp, u8 feature_index) /* ignore boost value at response.fap.params[2] */ /* init the hardware command queue */ - data->wq = create_singlethread_workqueue("hidpp-ff-sendqueue"); atomic_set(&data->workqueue_size, 0); /* initialize with zero autocenter to get wheel in usable state */ -- 2.20.1