Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2253846rdb; Sun, 3 Dec 2023 08:47:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IHHSLH2vXetBF7X+RcBs4HeLVirRv6EVNVyrx9EBNpX8tHrcaHusQl8otGqduO99zL10Nqv X-Received: by 2002:a17:902:a98b:b0:1d0:6ffd:6107 with SMTP id bh11-20020a170902a98b00b001d06ffd6107mr2395537plb.41.1701622046100; Sun, 03 Dec 2023 08:47:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701622046; cv=none; d=google.com; s=arc-20160816; b=gqw+AKn+nVnJwG0ameY5htXyunXIERPmmkiD9fGlN0yaBh4fKWiTwAIl63AaGSVmxl s5eMeTj/08GNeX+gDExzfgQwLdlWcgqI75+mKzV7QhfVx15z5l82pbSIPcYZkN7hk2Nf u3KRDknm0W+oC4XDDzv8rjXAQy5Jc7tH0HXfNNfVnSLNp076mzmGzohoXcO1rwotNm8e 3swb0bZiZDkJumPggEZx2F83cGERYZEBlDbSeLz3Ge4xE89ZPaYmat6PzbJJE7QPUC1O uub7vV3uacl5WfClTeiKDm9B2VLRNbQk657UozAcC4MIiKjq5f4v9aZiVf1HWWWqbrbC HYyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=XqEhjdCUEhgSRQMHNm7WceDAtyAPDpPFSop9FAZXPDQ=; fh=pBJC1o3jad0tmZMp10PWGHJofHhbgPkxSqvQvSfuh0c=; b=IawEioUfTCZio5Em82mELti6Hxq87eMF8HDsipjQC8quzUro4/w72dvC2b7n91uKbV Odv5mOZNIfCh0LV7Q1smA3bUw9WSrhAzWEHzXTAsKhnCa/EwwI/+KcU25kgygKydxbZ4 t4BLMfUQYuJzzTy9sT2rOzXVqHleU6+g6YTQ6bOb9/80oTRcSEhFcu79R//sT7RoJ/NY 1vLGPdOQIL7EktLntxlGZTakJX+Z4knRdyOwHPra6tB+kVj2HUsy/wkVCwpKOP9ewoC6 rX33dwOR9l7WCxlSP1O+p5Xq8k7SDjmxNP/c3bC/FGdE3IiYUzfJrrKtjvTku/Xi2q3Q sDbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=k2eki61H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id ik17-20020a170902ab1100b001d058a84699si4067055plb.516.2023.12.03.08.47.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 08:47:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=k2eki61H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id F3299806A422; Sun, 3 Dec 2023 08:47:24 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229772AbjLCQrO (ORCPT + 99 others); Sun, 3 Dec 2023 11:47:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjLCQrN (ORCPT ); Sun, 3 Dec 2023 11:47:13 -0500 Received: from m12.mail.163.com (m12.mail.163.com [220.181.12.198]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CC771D0; Sun, 3 Dec 2023 08:47:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=XqEhjdCUEhgSRQMHNm 7WceDAtyAPDpPFSop9FAZXPDQ=; b=k2eki61HONGLHP5P3jPJgr+HDZgJgFbz+J V20VHim35C0ePeAy/mfx5Cma/mzQEXnR310bOJMqT+/Ae+iA04qnnspBy4Prk/za 1+hdeltfrNVipyu3VMABXOwb/SCchzVFpaZqcfHkzHlZr8eYkUBXovXPZ/aveuYW ntUJs9RG4= Received: from localhost.localdomain (unknown [39.144.190.5]) by zwqz-smtp-mta-g3-0 (Coremail) with SMTP id _____wD3f80JsWxlMsRBEg--.16729S2; Mon, 04 Dec 2023 00:47:07 +0800 (CST) From: Haoran Liu To: dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Haoran Liu Subject: [PATCH] ipaq-micro-keys: Add error handling for devm_kmemdup Date: Sun, 3 Dec 2023 08:46:53 -0800 Message-Id: <20231203164653.38983-1-liuhaoran14@163.com> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: _____wD3f80JsWxlMsRBEg--.16729S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7Cw48CF43XrWktw1xtF17Awb_yoW8WrWxpa y5G390k3yUWw47Aw1DtF1kuryYya95XF4a9FyDK393uanxWFyktrn0krWSgF1kGrn093W2 q3W09rs8C3WYvrUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pRn2-nUUUUU= X-Originating-IP: [39.144.190.5] X-CM-SenderInfo: xolxxtxrud0iqu6rljoofrz/xtbBchY7gletkAhV1wABs8 X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_BL, RCVD_IN_MSPIKE_L4,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sun, 03 Dec 2023 08:47:25 -0800 (PST) Check the return value of i2c_add_adapter. Static analysis revealed that the function did not properly handle potential failures of i2c_add_adapter, which could lead to partial initialization of the I2C adapter and unstable operation. Signed-off-by: Haoran Liu --- Although the error addressed by this patch may not occur in the current environment, I still suggest implementing these error handling routines if the function is not highly time-sensitive. As the environment evolves or the code gets reused in different contexts, there's a possibility that these errors might occur. In case you find this addition unnecessary, I completely understand and respect your perspective. My intention was to enhance the robustness of the code, but I acknowledge that practical considerations and current functionality might not warrant this change at this point. --- drivers/input/keyboard/ipaq-micro-keys.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/input/keyboard/ipaq-micro-keys.c b/drivers/input/keyboard/ipaq-micro-keys.c index 7b509bce2b33..1d71dd79ffd2 100644 --- a/drivers/input/keyboard/ipaq-micro-keys.c +++ b/drivers/input/keyboard/ipaq-micro-keys.c @@ -105,6 +105,9 @@ static int micro_key_probe(struct platform_device *pdev) keys->codes = devm_kmemdup(&pdev->dev, micro_keycodes, keys->input->keycodesize * keys->input->keycodemax, GFP_KERNEL); + if (!keys->codes) + return -ENOMEM; + keys->input->keycode = keys->codes; __set_bit(EV_KEY, keys->input->evbit); -- 2.17.1