Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3471127rwb; Sat, 12 Nov 2022 06:21:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf588x7R5C8KZs3rxUk2NwB3pXRYIZbHOCqjdgtyUXez6M93CouGgxgmnvWMvAHkMA4ZBxwB X-Received: by 2002:a17:907:206e:b0:78d:3c82:a875 with SMTP id qp14-20020a170907206e00b0078d3c82a875mr5440507ejb.465.1668262863069; Sat, 12 Nov 2022 06:21:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668262863; cv=none; d=google.com; s=arc-20160816; b=WokXW220LckpuhM53sTpVNLtihIkt60EtjqZiZ/dWcNi8VAfJQkV8S+EdlRJz/C/As OwozyhspV3yQl7WOm6VfCoMoehVJL7kX/U3Nz6TCIi63Osd0kHLWFJZ6yPOzC135QqnY 8r78wCBEAslpW3H0pKkXGKYkw1oy9EHU6dKeWxqF5I+agt4cnUlX1g/SlUXKtyYIOOet DlCgHWLkXQp0KJ/SXnxhYPoY0XeoiMVQmFIl3ADyTaQR66cd4jb5wfmwGAIDtOknlBmq HZecBqabfR0QcXRJ9JqGiluSbtRXHBpsWSlBBIeug5TcZ9f8mKoTo1LerYkplUKMWh4e Qlmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:in-reply-to:date:subject :cc:to:from:references:dkim-signature; bh=8pO3EQslVSrJvjXJpPRM2Zh1IhtyM/gRBLzXNxwOb4Y=; b=iQVb1TGJR3I+EPSfBNc/p/pRAGXXFKxr3IKecW+2q97GkM2pk3LSMtZwT3qfBzv+Ad HaMR6Fqyscs8G3fZgRgCFMiI3LgmbbNJiknfgZ5LZNgUQnDma3H4UD9cf2Gmbbbepj62 7ISmj5oBLeD+87a8+QIoRH/VESU8UVmRdK3KuAxjxpX1qT2W/gNs3pqiRvPjHb6SMYNh L0BEI0a3WtUOOfM8KNibZPx/wq5UPTsUykm5g5KjwqExG/IP7S+xNmO/qJ9m+SS+dS/c 1miiNFUAamhNNOLaSZnGeInf7x93iTacTAMsnaZrHwXdM5EE5MiBSIkvEYn2IF1S5Y4e WVIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="hO5A/K/Q"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sh13-20020a1709076e8d00b007aeec2bf18esi510596ejc.529.2022.11.12.06.20.40; Sat, 12 Nov 2022 06:21:03 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b="hO5A/K/Q"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234728AbiKLOGZ (ORCPT + 91 others); Sat, 12 Nov 2022 09:06:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231404AbiKLOGX (ORCPT ); Sat, 12 Nov 2022 09:06:23 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6A18DE93 for ; Sat, 12 Nov 2022 06:06:21 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id k8so9904023wrh.1 for ; Sat, 12 Nov 2022 06:06:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:message-id:in-reply-to:date:subject:cc:to:from :references:from:to:cc:subject:date:message-id:reply-to; bh=8pO3EQslVSrJvjXJpPRM2Zh1IhtyM/gRBLzXNxwOb4Y=; b=hO5A/K/QFUPj/rOawOJCNaYLb7uaRGP6g2iJ7KM7f5D1D075sC5YqznkdDdmKqQsYJ BwQGgzVmaqmXM9m6Fpo0+dPF19G8BY5+uyx7Y2GiO3litIv2x6eJj29/JkysoDBo37Ec 4S8oznqgZiqpqFub0UeHV5ObWQMOTWjn0dEMYwJlmnKeB9Tbb34vWA7bNSgvaL9AgPcm sGZ7121szu76Gji0lCKRLJexf1PluXQPcIIHAc50whX0aVDA1s4k3DqeWo8AVrhZPQvk cqxVvRvScMWct0CFwuU9Hu4h49hExaeqCU+t5PlrLAnItD1MA5a1Hq2ybtw72t3tRwGq dt2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:in-reply-to:date:subject:cc:to:from :references:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8pO3EQslVSrJvjXJpPRM2Zh1IhtyM/gRBLzXNxwOb4Y=; b=j9EENe8/l64FXJb/gM5e4BZHwhNV1Q6H7yEvVnxIRvFiQKJTjmdyt3RVeGSOZj6r4S o26SnND9NiadYHQ8WrAEl7LgBezPTtqzA4gBW4frZbljZ5Mi7Barx7LZJs0uFyC33NWi Kh+cgrI1jlhCJGTk5Dor79HLsHuPuw8SIAuIgrZQ69k3po9cqKi/FlJgCcDOKoiOX3tl kl2ak9PEO70K+jrCGlLB/3swjL2prU77IzNp20R/DHcX6gkcTJuebHJf3FgbforZR+Sy XlSFqxgNgKuE5HYdK79aqRFdDp+zElSXc9ACKJEWLpdFjmX1Sg3PZCppgGor29PFVPzP gABQ== X-Gm-Message-State: ANoB5pkJuGRHvTcuJE9Kf295gSCFs1kiIpCZb8y+h8/T1JhziaEKJbwY ybww4T1cCIuz7ohmVp5jEF8= X-Received: by 2002:adf:ee10:0:b0:241:717e:fbea with SMTP id y16-20020adfee10000000b00241717efbeamr3629500wrn.77.1668261980209; Sat, 12 Nov 2022 06:06:20 -0800 (PST) Received: from localhost (94.197.38.186.threembb.co.uk. [94.197.38.186]) by smtp.gmail.com with ESMTPSA id k3-20020adfd223000000b00236e834f050sm4350537wrh.35.2022.11.12.06.06.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Nov 2022 06:06:19 -0800 (PST) References: <20221107202114.823975-1-y.oudjana@protonmail.com> <166811478949.1075638.10692622037510321259.b4-ty@kernel.org> From: Aidan MacDonald To: Mark Brown Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Yassine Oudjana , linux-kernel@vger.kernel.org, Yassine Oudjana Subject: Re: [PATCH] regmap-irq: Use the new num_config_regs property in regmap_add_irq_chip_fwnode Date: Sat, 12 Nov 2022 13:52:35 +0000 In-reply-to: <166811478949.1075638.10692622037510321259.b4-ty@kernel.org> Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-1.8 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_NONE,SPF_HELO_NONE,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 Hi Mark, Mark Brown writes: > On Mon, 7 Nov 2022 23:21:14 +0300, Yassine Oudjana wrote: >> From: Yassine Oudjana >> >> Commit faa87ce9196d ("regmap-irq: Introduce config registers for irq >> types") added the num_config_regs, then commit 9edd4f5aee84 ("regmap-irq: >> Deprecate type registers and virtual registers") suggested to replace >> num_type_reg with it. However, regmap_add_irq_chip_fwnode wasn't modified >> to use the new property. Later on, commit 255a03bb1bb3 ("ASoC: wcd9335: >> Convert irq chip to config regs") removed the old num_type_reg property >> from the WCD9335 driver's struct regmap_irq_chip, causing a null pointer >> dereference in regmap_irq_set_type when it tried to index d->type_buf as >> it was never allocated in regmap_add_irq_chip_fwnode: >> >> [...] > > Applied to > > https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next > > Thanks! > > [1/1] regmap-irq: Use the new num_config_regs property in regmap_add_irq_chip_fwnode > commit: 84498d1fb35de6ab71bdfdb6270a464fb4a0951b > Um, this does prevent the null deref, but the fix is in the wrong place: d->type_buf shouldn't be accessed in this configuration, the bug is in regmap_irq_set_type(). The access should be guarded by "if (d->chip->type_in_mask || d->chip->num_type_reg)" to prevent the NULL deref. The analysis in the commit message is inaccurate, >> However, regmap_add_irq_chip_fwnode wasn't modified to use the >> new property. the proposed fix is just wasting memory, since type_buf isn't used except for the erroneous write -- the write shouldn't happen at all. Regards, Aidan