Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1802290pxp; Mon, 7 Mar 2022 02:41:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJwTrLufGlkREPX8ZER5kqNf6hy0D83yLaiQH7LA3bgGR5QVu2+hxggiu4kETHLXZ5cpCbaE X-Received: by 2002:a17:907:7d94:b0:6db:207:c0cd with SMTP id oz20-20020a1709077d9400b006db0207c0cdmr8339441ejc.362.1646649691011; Mon, 07 Mar 2022 02:41:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646649691; cv=none; d=google.com; s=arc-20160816; b=z/ID4AT0l1Br6crpLrnOwVD5BgRtec0SEunVwRo8+luer8QfYiIrAPIVPxq+pQO5uB d9+Du0TbebC/FHpxgQpL4eShStec+yjbW/zLXFzSQM+ZyQPMnTUGWpXeyNF8byK0USHT dBP2onMMRjFCwll5V8noPOiK/zrB0GpyuE5IT79dQgxfDaqU43Mb2U3dHSK9nR2Bo1IM BflgAc1BmHEp/B2m0AGyO8WSGz2MSBOIRMRgvN6GV9mCeRyIpqGGnmXbgyup6Zow4xXw ZPOvNNDQROK2Z8gwyUQ1B3WOIswS8gf3qRcQJgfUB+etkh7weyascbMNEo3IX+uzQTm+ olWw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oijsjXXgOeFnxtBzTCpA9vuLM1EKQWiKdUmU2D/e3N0=; b=ywiqrF0lDo0mmq14+JueHt92pyt1ACSyPqG3TZVnjTYXNeXQLk/GG42Z0rh2fG8RSa jFYnkQN5w1SUTxWQf1fHtwS1txtDQrw0mFkGLyPuYoxcgvte1o5f1+zS4I8fA+8LO5No aRDk+tT1ggboNbpeAmXG30fSCZecchKHs2plKMepIMbyQNv909UbCFB3RYaYZ3kVUdvV WdS9KJrGvgVCYl5uwBDHi2MkLAsWamrEouDlHGq4Qtu2XJSSbivG2z2jTFgqpAcErFgP ILwduslWHI+usF1dJF5IWSbH0jOSPOevpxLzTeCbLeG5l0VjRan1A+TYYdS/K1LCUFcY xy7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Vpj4z3u3; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g9-20020a170906c18900b006b259e56d18si7483543ejz.272.2022.03.07.02.41.04; Mon, 07 Mar 2022 02:41:30 -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=@linuxfoundation.org header.s=korg header.b=Vpj4z3u3; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234262AbiCGKNm (ORCPT + 99 others); Mon, 7 Mar 2022 05:13:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238919AbiCGJ5f (ORCPT ); Mon, 7 Mar 2022 04:57:35 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F07B97B560; Mon, 7 Mar 2022 01:46:03 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D2C7A612D2; Mon, 7 Mar 2022 09:46:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD927C340E9; Mon, 7 Mar 2022 09:46:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646363; bh=vr0+wwaEZAzHQoUwmpetBlQ5szZb4b7r+VodDSiJkzU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vpj4z3u3VPHrx9PDjV6b5yFH1Mbl6rrBNsIot/e8kjWjw7WfL2XxJV6GehCreSnfk MjsOYt9FF9dYCQkwlG8Q3eFSJfZ0f5lDeUxVOJVVJEC74baI8ME7a1kZCw/SE+rKHj EJTPJud5Px3KRdFz3Yzd0k0w4iItDc4jk8od3occ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zheyu Ma , "David S. Miller" Subject: [PATCH 5.15 179/262] net: arcnet: com20020: Fix null-ptr-deref in com20020pci_probe() Date: Mon, 7 Mar 2022 10:18:43 +0100 Message-Id: <20220307091707.469022799@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091702.378509770@linuxfoundation.org> References: <20220307091702.378509770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: Zheyu Ma commit bd6f1fd5d33dfe5d1b4f2502d3694a7cc13f166d upstream. During driver initialization, the pointer of card info, i.e. the variable 'ci' is required. However, the definition of 'com20020pci_id_table' reveals that this field is empty for some devices, which will cause null pointer dereference when initializing these devices. The following log reveals it: [ 3.973806] KASAN: null-ptr-deref in range [0x0000000000000028-0x000000000000002f] [ 3.973819] RIP: 0010:com20020pci_probe+0x18d/0x13e0 [com20020_pci] [ 3.975181] Call Trace: [ 3.976208] local_pci_probe+0x13f/0x210 [ 3.977248] pci_device_probe+0x34c/0x6d0 [ 3.977255] ? pci_uevent+0x470/0x470 [ 3.978265] really_probe+0x24c/0x8d0 [ 3.978273] __driver_probe_device+0x1b3/0x280 [ 3.979288] driver_probe_device+0x50/0x370 Fix this by checking whether the 'ci' is a null pointer first. Fixes: 8c14f9c70327 ("ARCNET: add com20020 PCI IDs with metadata") Signed-off-by: Zheyu Ma Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/arcnet/com20020-pci.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/net/arcnet/com20020-pci.c +++ b/drivers/net/arcnet/com20020-pci.c @@ -138,6 +138,9 @@ static int com20020pci_probe(struct pci_ return -ENOMEM; ci = (struct com20020_pci_card_info *)id->driver_data; + if (!ci) + return -EINVAL; + priv->ci = ci; mm = &ci->misc_map;