Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp227986rdb; Fri, 6 Oct 2023 01:22:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEwCIl1wxn0a4oUQmSpmtubs53HUld8IvD+Dzgd45KhjL6hVa1O3GJAdQSlVfB7Uh/gGxLl X-Received: by 2002:a05:6808:1489:b0:3a8:5133:482d with SMTP id e9-20020a056808148900b003a85133482dmr8275181oiw.35.1696580522900; Fri, 06 Oct 2023 01:22:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696580522; cv=none; d=google.com; s=arc-20160816; b=gxP9Kg75NQeWNH4dXKRLrZqVmpIHRlghLUOvgMeL+TKBTftTIYFwp01GJdqDl5f6LZ twOhXBI8ophcFS2oKlghnEdnJxDKkvYvxS95YeIs8mU8Q0FZ4SN3wqQZs4nb4mToxcDP JCfbnnB9wyF4DwIuDF9wAR9dlk/JI2BnBSA3YjlGjmS96vFJI/Kd1keyyF+g/lrA19n2 +wpLOSRb8k3HrXAjm6xrx7jB8ohaG3Qm5pfPYpBSP7oQY/wWZbvnbG9LEJzuWlK/KoVO KHkLFGEqZJA+ZJZPxofSwhal07jE/FIV86E9IfS2IRjz1/Iq1MsQtgOrt5T2tICAolxc Tz0A== 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:dkim-signature; bh=Jxlpdz9tYbo+MYnuymydUJH0APPX24YNdQskN8Ew/rc=; fh=1Adqbw/eukceA0oOn1ahLpR52W1CLGC/THJYoPneshE=; b=RcN7mBsiUoANx4tiWp+lZVok+gOmIyn8ubIwO8jQd8pqabfO7dx2MqXlaxve6mJSVa EdFsXoVooWxSwTdSHnw7bhpGVUN7JhgKMzA9gYDKFBtpC9Eekcl5MM4wpzfRzy01hpvj B0KI37TaR4CwZT40Y+orWHGf37yLS6gk4P6YfDu9Twrrc76Mzvu/S18MzlPh5fmrgn1U Aqw8XTNKby3CnFBvn3KuHD0MhiAZl5BNVQ5/lQbxV4h4kETFsJUVRdNoJQKJofj7pwM8 YIfVOGlSbG+ffLGixOr/N3tSOCSJm/lXwQ1ZzkyRKUz6bKM6nSVv/9gAbEPLUNEUzjEw Z4DA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="br3bgF/3"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id m2-20020a655642000000b00578afb3123bsi3244680pgs.700.2023.10.06.01.22.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 01:22:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="br3bgF/3"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 47F488080E06; Fri, 6 Oct 2023 01:22:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230493AbjJFIVx (ORCPT + 99 others); Fri, 6 Oct 2023 04:21:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230344AbjJFIVv (ORCPT ); Fri, 6 Oct 2023 04:21:51 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B801E9; Fri, 6 Oct 2023 01:21:50 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DBEBFC433C7; Fri, 6 Oct 2023 08:21:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696580509; bh=Rleyk+ijWu/nDpxQgC3SNjU9qlvK6Ft6iDjWmhbKDIY=; h=From:To:Cc:Subject:Date:From; b=br3bgF/3/cRbaRJkBy3sRCjuWMUfnImgEykeBlfA8FIxEy2wPP8oSIi8IElBxVS/F BybGhOPmrxEKJfWzLGitiqFsXcVfNxxuCMctgyKZ7DWbYjSweS1CDFznttr1R/O7ED mrdpUTgGvPM4k+VaVLycb8ZeScw/wikpXbRP9poFuj954GaWiXiGGrMhY5kxxBPsYJ aW7NL9cpr4CGsLsRT1G91GUrR0SSRkvTR8zZTCBG+k7Cufy5hhijjW7eDsEIuOJhgF iFWyt8b+ta9VFf/OO1aKci9OBm/hgAaHgJo7VSpIfceLuTTgltILJ2CkcyANzlIUKZ v71a5H2bfqo3Q== Received: from johan by xi.lan with local (Exim 4.96) (envelope-from ) id 1qog63-0004M8-2O; Fri, 06 Oct 2023 10:22:08 +0200 From: Johan Hovold To: Mark Brown Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Marc Kleine-Budde Subject: [PATCH] regmap: fix NULL deref on lookup Date: Fri, 6 Oct 2023 10:21:04 +0200 Message-ID: <20231006082104.16707-1-johan+linaro@kernel.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email 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 (groat.vger.email [0.0.0.0]); Fri, 06 Oct 2023 01:22:00 -0700 (PDT) Not all regmaps have a name so make sure to check for that to avoid dereferencing a NULL pointer when dev_get_regmap() is used to lookup a named regmap. Fixes: e84861fec32d ("regmap: dev_get_regmap_match(): fix string comparison") Cc: stable@vger.kernel.org # 5.8 Cc: Marc Kleine-Budde Signed-off-by: Johan Hovold --- drivers/base/regmap/regmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 884cb51c8f67..234a84ecde8b 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -1478,7 +1478,7 @@ static int dev_get_regmap_match(struct device *dev, void *res, void *data) /* If the user didn't specify a name match any */ if (data) - return !strcmp((*r)->name, data); + return (*r)->name && !strcmp((*r)->name, data); else return 1; } -- 2.41.0