Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp70244imn; Tue, 26 Jul 2022 23:08:05 -0700 (PDT) X-Google-Smtp-Source: AGRyM1slCrd9D3D/d5o65uda7lDTEYHkhdDAysLlejugtjy3ye/3+QL2hnmLfFme+xRgfkxWCRSe X-Received: by 2002:a17:907:94cb:b0:72f:1d8e:7305 with SMTP id dn11-20020a17090794cb00b0072f1d8e7305mr16639779ejc.625.1658902084814; Tue, 26 Jul 2022 23:08:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658902084; cv=none; d=google.com; s=arc-20160816; b=ybF5WT1VPmr6Azwz94AiKMo4jk9ylAt2yLRGYFRZ6Pz4+slcfEebvJGprDk5S/UFqB 3HLvctCDXdHUM61YCBudpE2MvIik2syTNR4P/2f9+3hAIgu40sLenC5e5xueF4vXS0f3 JhKRakY/u8rXDIINUoyCc6DoOagpIUKIVh+p/dEuYg1uVuRJDzmMC+jsuDgwlJ3/eJv3 AYBhLAKfJhWE1faEL+R9ThDt3cBPiHvoq39MekhhRRFZCkiDsyVnX6kBF+is4RUN2uPD /tNEyBLcjc71mbNcNV38n0svfV10KK7Z0zamt+VrrhhgHslM+viRD3ABZnE4yE2Qw8Em GmzA== 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=pHInnhZIapp9ygsJkxHnw8j0AydAm5/Szf/QJZReVwc=; b=zLZDrBwv9rOf9773htTZybXjn3DhB66YM4eflHFU0UQt8vxSCosm5vqgZJK6M39yCH tZX4sXlSqi0aj7Drzjq6DaVlbM2W+/7QYQDpc982kuDA0l5hqpNYJF4lRPSyuWE8gwpM LUGqEFjP3Fb2s4lMOoHAiW2MalrMizMyBQOfBqvfyi55Svtwmg6CxJVQfQfW7vYCzlru SF5SvPI922hUr3Ax6Kn3WWDhdLBnjtHfYhBAnzqSQeATLvgS8WAPXybnyFad9z+tkqHA 6q01xQi00ZNZpvSpmY65SG2Rxt5uB9iAXrUyNX7fYrRC9bDIX52bi+0vYLrjT77LnE0z xDmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hOvYEhU9; 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 gv43-20020a1709072beb00b0072b1307863esi8169618ejc.122.2022.07.26.23.07.40; Tue, 26 Jul 2022 23:08:04 -0700 (PDT) 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=hOvYEhU9; 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 S229762AbiG0GDR (ORCPT + 99 others); Wed, 27 Jul 2022 02:03:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229499AbiG0GDQ (ORCPT ); Wed, 27 Jul 2022 02:03:16 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 645752A735 for ; Tue, 26 Jul 2022 23:03:15 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id z3so15302287plb.1 for ; Tue, 26 Jul 2022 23:03:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc; bh=pHInnhZIapp9ygsJkxHnw8j0AydAm5/Szf/QJZReVwc=; b=hOvYEhU98x/GDtGnYnmoR6BJRBXACIoTfxIQJjyK99pcrQKlqKNDGNPCCYvtelWyQZ Y183bzy65rDmM1fHouJFY5e0lrHP2DA9cKq0IlsKAlZP4ykSykOuwcz45eXUJsECIkle 4QKLBROzWhdgL0/SYmLwbPvvfb4CZI6QgsS1oLhLUB1IiQ8o6Xu3pTgvADuCETctHgQd 3jXASagP1pGOOnh0jhs5ikPcA8d9CtYGSAujv/q62h9Q70hMpicy3GAHNw+nqitfpaG/ KuGd3q+ZwR1SrHcxOZAo5iWuejtHg7RvbLN2OnmlD5lrihO9XLpQ8t3iTyoV88opuaSb hOuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=pHInnhZIapp9ygsJkxHnw8j0AydAm5/Szf/QJZReVwc=; b=5FQWM3wlndc3cu59kBonBnwVW4QMPLDln9nAHlZrm8reOdZpOIjcsHJ398JPITdUA+ FBMiE+T38+d2rgJNdhPeed50ZpVmp6+dwE25RLaygxnSIohR0lBIjEhDksrlt74NxTeK dFKqx0QX8SEqKSElbGdUoVt6cS1X/BV+/dCynBvGSalj974b33Cp3xw9b+qZShlT62eM xo+URz1jHuZ8wWBH6MAAS1SbV9RwjNZeFHO9aXhsZKRnsHeikNrUqa0BP0QzUZpvhiOR OM06MAkgOD3dFAkW10tDf7jdGOcqrGx7ooxzNMIcZ0whJEAUYN1Qae+BSl6EsO+bCVOp FS+w== X-Gm-Message-State: AJIora/7oQ7bxebeywTBiPgwT4nvukwd7vphCzwVDDxWYpxfDrkWU2Z1 pDKzgg/98egCWqjEb3pAOpo= X-Received: by 2002:a17:902:d2d1:b0:16d:37b3:f8b3 with SMTP id n17-20020a170902d2d100b0016d37b3f8b3mr19612626plc.98.1658901794902; Tue, 26 Jul 2022 23:03:14 -0700 (PDT) Received: from localhost.localdomain ([43.132.141.3]) by smtp.gmail.com with ESMTPSA id j1-20020a654d41000000b003fadd680908sm11252628pgt.83.2022.07.26.23.03.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 23:03:14 -0700 (PDT) From: Zeng Jingxiang To: miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Zeng Jingxiang Subject: [PATCH] mtd: physmap-core: Fix NULL pointer dereferencing in of_select_probe_type() Date: Wed, 27 Jul 2022 14:03:02 +0800 Message-Id: <20220727060302.1560325-1-zengjx95@gmail.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 From: Zeng Jingxiang Coverity complains of a possible NULL dereference: in of_select_probe_type(): 1. returned_null: of_match_device() returns NULL. 2. var_assigned: match = NULL return value from of_match_device() 309 match = of_match_device(of_flash_match, &dev->dev); 3.dereference: Dereferencing the NULL pointer match. 310 probe_type = match->data; Signed-off-by: Zeng Jingxiang --- drivers/mtd/maps/physmap-core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mtd/maps/physmap-core.c b/drivers/mtd/maps/physmap-core.c index 4f63b8430c71..69d0ab1f6f94 100644 --- a/drivers/mtd/maps/physmap-core.c +++ b/drivers/mtd/maps/physmap-core.c @@ -307,6 +307,9 @@ static const char *of_select_probe_type(struct platform_device *dev) const char *probe_type; match = of_match_device(of_flash_match, &dev->dev); + if (!match) + return NULL; + probe_type = match->data; if (probe_type) return probe_type; -- 2.27.0