From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,T_DKIMWL_WL_HIGH,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 311F0C04A6B for ; Mon, 6 May 2019 14:44:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 04BE5214AE for ; Mon, 6 May 2019 14:44:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557153872; bh=U06b+7SMOd1T5Eb9THRyiS8fJZVFDZ3S6Ub8K/YqRqM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ClAq1tEN4OOY47JQapJFO5J/jhG6QTaK/jmeMDZlp0cacI/KNQfA60zQKqC2SFwzx +LYtubKeuLwu+i1Jcx/l/nJuArnUDLoztMQLHr9W93YV+4UW7fkPAhAUaj0xBNvf5N 2LIUyD707NvjNCIjzxsHEhz2YyEa/IBxCcuSveqk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728815AbfEFOoa (ORCPT ); Mon, 6 May 2019 10:44:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:40746 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728549AbfEFOo3 (ORCPT ); Mon, 6 May 2019 10:44:29 -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 E4DFB214AE; Mon, 6 May 2019 14:44:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557153868; bh=U06b+7SMOd1T5Eb9THRyiS8fJZVFDZ3S6Ub8K/YqRqM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ti6udXuktaYYjtz9e4jEHIVz1N3Ce0x2wMDrhIfgJGOXZ3f4BIJUq5zIyFWOSlFF5 Cy1YQzrK72mZIkM62AcXu29TEaDSPsYdpslYUPIOSJKe2dDO47W1r3C4Fz5ZJejH6h e1l5QaqZn1zvYeAWk9na0wxHZEC3OmmDw+V3JbvA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kangjie Lu , Jiri Kosina , Sasha Levin Subject: [PATCH 4.14 26/75] HID: logitech: check the return value of create_singlethread_workqueue Date: Mon, 6 May 2019 16:32:34 +0200 Message-Id: <20190506143055.544147223@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190506143053.287515952@linuxfoundation.org> References: <20190506143053.287515952@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 --- 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 614054af904a..b83d4173fc7f 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -1907,6 +1907,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; @@ -1951,7 +1958,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