From patchwork Sat Feb 3 17:39:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 10198627 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 53A3E603ED for ; Sat, 3 Feb 2018 17:40:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C1B828F7B for ; Sat, 3 Feb 2018 17:40:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B9AE28FE5; Sat, 3 Feb 2018 17:40:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E0C9C28F7B for ; Sat, 3 Feb 2018 17:40:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752720AbeBCRkG (ORCPT ); Sat, 3 Feb 2018 12:40:06 -0500 Received: from mout.web.de ([212.227.17.11]:47175 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752604AbeBCRkF (ORCPT ); Sat, 3 Feb 2018 12:40:05 -0500 Received: from [192.168.1.2] ([77.181.226.140]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MCqoJ-1eZSw93HSl-009hl6; Sat, 03 Feb 2018 18:39:58 +0100 Subject: [PATCH 3/6] hid-prodikeys: Move an assignment in pk_probe() From: SF Markus Elfring To: linux-input@vger.kernel.org, Benjamin Tissoires , Jiri Kosina Cc: LKML , kernel-janitors@vger.kernel.org References: Message-ID: <44c2767f-c66c-3b36-4bd1-059d5d2f4461@users.sourceforge.net> Date: Sat, 3 Feb 2018 18:39:58 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Provags-ID: V03:K0:h3jvNAV47FYrnofI/3q7mApIqEJNE2mzaf93PhY1W+QjZ9YFJGO cLUY+PYt0t5DOnA2I4kM4tWYOYic+La3s4dkJ8agsKT29h2s6RrQ64TyGBwa0APYbx9E+8M gKIksFqE7Kj0fTIGLvC6WvYJIwefLSJ/GjQ1xJscHSKbdLbUIUz6jBuTcbtOc/QykjYfYwN f1RehE+qoaTB1l23doFJw== X-UI-Out-Filterresults: notjunk:1; V01:K0:Oj/x0T0zxBQ=:jkUt7t8MFzPbm3sFscReW8 9s747qqGvdrpbeZT5VDXLdOQHR7m3pBO0qUk3DTztq4i591zm6rulnwqhNanFyQQJ9/CY1f5C MAZxlC/4VswQYFRDn3tjJTYVK++p+WK88/Y2yFllGqx6ytaq/UOPq4DKkTK3+RY8x3k067fBX a9F7yleoSh0d5PrgtstYE25qtoonJNOqecei2tOg2cRRNEWJ5jUaJ4XFsQHoGMzKN1AxP4hTg OxK6aiOpV6noRbxGMamPJEhm4TT10cifVos6TF7/vHNA2p2pIeLmuZ9UFW1Q4fwGXZXnDFYqj T/QvDBx+AYe0vtfMWWqE+j135/Nh+18VBEy71aXsRSj565ZWlpOxRM8BHSjn1STRjbiHibPyB WXZ8+9P+X3H39tP9VerUcb89LKpJe2dkKXJ6umurGKVaq4hB0RuvsdceBgQUjzAQSc9F98Tjh eV0gmkbf8oV0I+qxzrvk9ygKukmJTAYZ/B+BlIUkrtziees3qSRPGOcCT9vFfYfvQIBj2z4C7 a9HBYvkcmcJKx5ncNI7Iyj6vJ18iVRiRlwdlNkXoCQ86QWSdGgX/svFnwNbyAUukXL68SwRrF pkQ517eJLJnV6p01qjo9oclv50cwXfX7gfXORdmwMKYH5BlqManrgR3oEZizolzR+mBcoI2J/ OfuLAP6AUJ+r994ohs2DqQMQ+Bxm6cLsIE+7ehHyjet775td92eEf2a3wFT4aNXtdgJShdfHW v3ivyFcSjLmIbZpyyTBBUA3aMFw+w1zmQrxcS8rjux1uPMxu9oW/frMitnSXB34mTuoc5KQkW Xt1CNM8qDjgB3Ex3IZjj5DHnmjOSDqMkIZfqoyUH50IujO44Pg= Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sat, 3 Feb 2018 17:20:01 +0100 Move one assignment for a data structure member in one local variable so that its setting will only be performed after a corresponding memory allocation succeeded by this function. Signed-off-by: Markus Elfring --- drivers/hid/hid-prodikeys.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/hid/hid-prodikeys.c b/drivers/hid/hid-prodikeys.c index 2e79dfc92162..7672f723b268 100644 --- a/drivers/hid/hid-prodikeys.c +++ b/drivers/hid/hid-prodikeys.c @@ -804,8 +804,6 @@ static int pk_probe(struct hid_device *hdev, const struct hid_device_id *id) if (!pk) return -ENOMEM; - pk->hdev = hdev; - pm = kzalloc(sizeof(*pm), GFP_KERNEL); if (pm == NULL) { ret = -ENOMEM; @@ -814,6 +812,7 @@ static int pk_probe(struct hid_device *hdev, const struct hid_device_id *id) pm->pk = pk; pk->pm = pm; + pk->hdev = hdev; pm->ifnum = ifnum; hid_set_drvdata(hdev, pk);