From patchwork Wed Jan 12 23:41:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Ruffell X-Patchwork-Id: 1579398 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=FQ8dH1AA; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JZ3xC6HtPz9s1l for ; Thu, 13 Jan 2022 10:41:35 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1n7nFA-0002vx-Np; Wed, 12 Jan 2022 23:41:28 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1n7nF9-0002va-Gv for kernel-team@lists.ubuntu.com; Wed, 12 Jan 2022 23:41:27 +0000 Received: from mail-il1-f200.google.com (mail-il1-f200.google.com [209.85.166.200]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 57E593F175 for ; Wed, 12 Jan 2022 23:41:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1642030887; bh=JDU4dqdxdUvicOeTaqCIh6z4NY/hBZlJJ7HS++pfOlA=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FQ8dH1AACChJ+rsZZ//TmIgR5eaSE1ZuDkJ2rQApHB85dNG7ZLayJrDhm9+i7t7rQ EEruGymeUBT3QUpaW6cZWw9XPVi0wynNWEXGpONHw0q0bfbZBFcoPfGicm9mMlUkt9 plRtrRie4eAbQw8hChk3TIBEcb/xzpxAtQk2MG5jq+Q0TuQf3r5qE+o/djR7scB+JK j8X2Jg+SFtAbKoEgckCSiSgaDPbeIBk9BYVw6qT+eMWRs0KtOY96syw9e/2z2MrmXm WY0Y28XE7yNmWU9QGRz14HaY3uV/AP3Scg5xgYZW6lnoQnE8VsMfsLgzdzLBgNN8eX +0R46o5g8jiSQ== Received: by mail-il1-f200.google.com with SMTP id d8-20020a056e02214800b002b766d01bf5so2684061ilv.18 for ; Wed, 12 Jan 2022 15:41:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JDU4dqdxdUvicOeTaqCIh6z4NY/hBZlJJ7HS++pfOlA=; b=PJAt8tPkmX55rSi1uRxBHtz/y0iAZfnXH8tfwJUH4+MpFRJ9NA06vYl2zZ86PeEbnW 2KfatmF5nZuI+/esMkLfUEQpDYgFh5tfAaPEBQP7GF0wGJlyLu11qA+SJK18Nd2+LiRg AcMTs+ugP2wpDq5tfV+8hmyTtqAr7BcXVERb707G8gSTDljXkrNC+b09fzlgHN32OOrT TV29VzS7uRXhuPoZ+aVzblYefdJvuxpb08rcBQCO+Z8g6fTtnDPSGCfXhF5AG/n12f/u 2201bQe406WoeMEQhd8L7ssmK3GsZlV16HHRKqUtGMPZ5B2g77jXmUVr1L1W54OvnaZw uj6Q== X-Gm-Message-State: AOAM532VmlODTwgjnb+oHKDNw1l+lViJbAqerkgaEnHMaHD+Y8Kwi41f EdpLLSHDQo62ko4pz33/48kQNfHl/jTu41irEqt8OY9lYrmvNd5Dgp12Zs83pI9y2sOcSO1ZdrW INt6HJWl4FLwEz6nNZazJ0uXIt7p8RlP4B8GqrSMpaA== X-Received: by 2002:a02:ac13:: with SMTP id a19mr947258jao.80.1642030886147; Wed, 12 Jan 2022 15:41:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJyOEyVod/7s5gBM7ifYkKvQ8wB7/NpmqzahPdcDhXk4rinRfuHlqlTZ7tMvE2GmbLYI8E9lIg== X-Received: by 2002:a02:ac13:: with SMTP id a19mr947251jao.80.1642030885570; Wed, 12 Jan 2022 15:41:25 -0800 (PST) Received: from desktop.. (122-62-52-82-fibre.sparkbb.co.nz. [122.62.52.82]) by smtp.gmail.com with ESMTPSA id c18sm798949iod.18.2022.01.12.15.41.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 15:41:25 -0800 (PST) From: Matthew Ruffell To: kernel-team@lists.ubuntu.com Subject: [SRU][Impish][PATCH 1/1] HID: amd_sfh: Fix potential NULL pointer dereference Date: Thu, 13 Jan 2022 12:41:15 +1300 Message-Id: <20220112234115.11152-2-matthew.ruffell@canonical.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220112234115.11152-1-matthew.ruffell@canonical.com> References: <20220112234115.11152-1-matthew.ruffell@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Basavaraj Natikar BugLink: https://bugs.launchpad.net/bugs/1956519 The cl_data field of a privdata must be allocated and updated before using in amd_sfh_hid_client_init() function. Hence handling NULL pointer cl_data accordingly. Fixes: d46ef750ed58 ("HID: amd_sfh: Fix potential NULL pointer dereference") Signed-off-by: Basavaraj Natikar Signed-off-by: Jiri Kosina (cherry picked from commit 88a04049c08cd62e698bc1b1af2d09574b9e0aee) Signed-off-by: Matthew Ruffell Acked-by: Stefan Bader Acked-by: Luke Nowakowski-Krijger --- drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c index 7af157b09a52..428f3a02f7db 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c @@ -235,21 +235,17 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i return rc; } - rc = amd_sfh_hid_client_init(privdata); - if (rc) - return rc; - privdata->cl_data = devm_kzalloc(&pdev->dev, sizeof(struct amdtp_cl_data), GFP_KERNEL); if (!privdata->cl_data) return -ENOMEM; - rc = devm_add_action_or_reset(&pdev->dev, amd_mp2_pci_remove, privdata); + mp2_select_ops(privdata); + + rc = amd_sfh_hid_client_init(privdata); if (rc) return rc; - mp2_select_ops(privdata); - - return 0; + return devm_add_action_or_reset(&pdev->dev, amd_mp2_pci_remove, privdata); } static const struct pci_device_id amd_mp2_pci_tbl[] = {