Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp3450843rwj; Mon, 19 Dec 2022 19:12:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf4VBuGl9Kj7aJ1sVAeoiTlesMT6Ta0hAFXdezn46IW5tSiw7eAeBTmco4Fs3zQzqDc8xXjc X-Received: by 2002:a17:90a:8a8b:b0:219:158d:61c2 with SMTP id x11-20020a17090a8a8b00b00219158d61c2mr46135303pjn.19.1671505977785; Mon, 19 Dec 2022 19:12:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671505977; cv=none; d=google.com; s=arc-20160816; b=ltFE4jA1Gwvy/ayIJYuyXqh7pCzNCbka0jNedH+cmTJe8N2iJ7OhAqXJ22GEZa5a5+ XwdnHoadC53y06sr2N7Bi4W8B7vU76QlA+DEFitCwLRoaJglcWcjpKTJcI6MJ1ozbOQ/ 7EXIQnOUFP+WNEXmDv8YSBUobhllmDqSljjnmsxCCV8nmcW/xpvUHFEemHupwa6eo45u Vrq6eBLnkSmwrlruJ4Lml4TwWvadg1WI/3KJ3lFMK34G5aAlHyV+OXlLYO/ktDlz189U nm1dzNXMLrIAwiK3TlzAeRUkrIZxT3mEF0ikq2HXZ9jX8JGS22aZLoIuzBu3og4JRX63 tzvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=cEYbNo2ZT7WZ7oduOUV8s7nGrSadeVKz/TTA/jVDaVo=; b=EDU7cuuBGx2TlJ+6Xo5QzJwm8Rzc7SCKCIKHNJqheJmhIsg6BQX3tm1aa2VEopv5N+ vEPWLmh1CXtlGiCY3p8tV26RCwO9OaZQWiXCT07nET3vlAogKtduTqCtgWZnfWFnymfk C2c/1KN7TDSFcnsFRsRDvtue4z1WxkhH9BRmkO6ySj7OScbn8uD3CIRcSQ4MWOtO9gIA zPHkUrn1Oz5NFm6kwBKVYIzZJUeSECO6d/5r07UgEkrMRQw6ihjz0oJLmt/sTkmO09Ua oim1uaV2ekpf3EvfRP3CZrPLSAb4JbbqSdyBtVwfP1JxA69I3MwC/yM3pUX12fEiDRfy NIVw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v37-20020a631525000000b0047712cb3fe3si12782776pgl.590.2022.12.19.19.12.48; Mon, 19 Dec 2022 19:12:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232248AbiLTCte (ORCPT + 70 others); Mon, 19 Dec 2022 21:49:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229647AbiLTCtc (ORCPT ); Mon, 19 Dec 2022 21:49:32 -0500 Received: from cstnet.cn (smtp23.cstnet.cn [159.226.251.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E112413CC6; Mon, 19 Dec 2022 18:49:29 -0800 (PST) Received: from localhost.localdomain (unknown [124.16.138.125]) by APP-03 (Coremail) with SMTP id rQCowAD3_5eyIqFjUO2rBw--.35526S2; Tue, 20 Dec 2022 10:49:22 +0800 (CST) From: Jiasheng Jiang To: basavaraj.natikar@amd.com, jikos@kernel.org, benjamin.tissoires@redhat.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH] HID: amd_sfh: Add missing check for dma_alloc_coherent Date: Tue, 20 Dec 2022 10:49:21 +0800 Message-Id: <20221220024921.21992-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: rQCowAD3_5eyIqFjUO2rBw--.35526S2 X-Coremail-Antispam: 1UD129KBjvdXoWrZr48Kw1fCF1fKw4fKw4UArb_yoWDZrc_Ga y8XFZ7Xr93GFWSg3Wj9ry8JrWqvrW3XF1F9F1SkrW3Cr97Xr1xur4kAF1Y93WxCw1DJr97 JwnY9rWkA3srGjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbcxFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr0_ Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AKxVW8Jr 0_Cr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj 6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr 0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxkIecxEwVAFwVW8 JwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r 1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij 64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr 0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF 0xvEx4A2jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7VUbYhF7UUUUU== X-Originating-IP: [124.16.138.125] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add check for the return value of the dma_alloc_coherent since it may return NULL pointer if allocation fails. Fixes: 4b2c53d93a4b ("SFH:Transport Driver to add support of AMD Sensor Fusion Hub (SFH)") Signed-off-by: Jiasheng Jiang --- drivers/hid/amd-sfh-hid/amd_sfh_client.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_client.c b/drivers/hid/amd-sfh-hid/amd_sfh_client.c index 8275bba63611..ab125f79408f 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_client.c +++ b/drivers/hid/amd-sfh-hid/amd_sfh_client.c @@ -237,6 +237,10 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata) in_data->sensor_virt_addr[i] = dma_alloc_coherent(dev, sizeof(int) * 8, &cl_data->sensor_dma_addr[i], GFP_KERNEL); + if (!in_data->sensor_virt_addr[i]) { + rc = -ENOMEM; + goto cleanup; + } cl_data->sensor_sts[i] = SENSOR_DISABLED; cl_data->sensor_requested_cnt[i] = 0; cl_data->cur_hid_dev = i; -- 2.25.1