Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2925169iog; Mon, 20 Jun 2022 07:37:06 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uh1v1vqWoUSyS1rC3qn9ka3Fn3W3ZdUfuf+TJkrDDvmuLrjn+qJOAUxF8l6aNunOfA53hK X-Received: by 2002:a05:6a00:21c8:b0:4fd:f89f:ec0e with SMTP id t8-20020a056a0021c800b004fdf89fec0emr24529552pfj.83.1655735826607; Mon, 20 Jun 2022 07:37:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655735826; cv=none; d=google.com; s=arc-20160816; b=ncp4szILJ+1pN2K2z078UaexXPf/8uDEeTZjceelvGomf12SRzhp3LrUnisVO3H7ab isyfVDxTH7+NoALWRr0hGGfSaieVthF6cm7whh4I4s3R+H8CieZnAt1jf2PFUogS9xEq iIwh1Gq9/CyystTUoia5NlvvyAmCVPUK3QFYjzR+xQQnESZUW5xO8AbExMt9v7IteRaz CWO6Z/j0j9bNaqZOOpz4AZV7/amPFqwBqurAq5NAMWjecM8U4/A6td4w3N5W2SQqRJ4w x68wvFF29YrmC6RFYWEE13s4jXnW5UVjpY0xV7u5OS21ogG/ryRtw2A9XZHZ5vMvsgrM 9WrA== 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=sNmaTL6jBqdDlm9tg88u36wTWh/vVyTW/y97lxMj8Uc=; b=bUAuxGISMG+FDa1gEyc1NdJrvPqY+FCvHX1Oco6Ih6DzP2GHtR2/OMEQ6R4MLStvTd qsWzM/MTSRAteYd8bsE9asgGyQoeE/kUyCoXZQo/zoHtLuGZU6WNMr8PcykyETWlWCj5 uXydHSX6J800lJ+aCXVGMqtbgOnYTomTxR6FVS5ncy9SaIQtFqW5v8mzOjR/TZ9NON6h BwAgkblfNv3/Zk8GkAeCkka+Uwu1AQtaO91AKPgMY8KjIC9Cklv2HpLU3UgUOqXAog0n FIcnGMH9W0A4L5vH08YImAav85XXOVLFEdVfomdvVWwpTEa5/ePhA6yIq/oHu07CMIgc CUUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Y5pJ0G3e; 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 s2-20020a170902ea0200b0016366bfb1c2si14285274plg.424.2022.06.20.07.36.52; Mon, 20 Jun 2022 07:37:06 -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=@linuxfoundation.org header.s=korg header.b=Y5pJ0G3e; 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 S245363AbiFTNLL (ORCPT + 99 others); Mon, 20 Jun 2022 09:11:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244674AbiFTNH3 (ORCPT ); Mon, 20 Jun 2022 09:07:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23F7319FB3; Mon, 20 Jun 2022 06:01:00 -0700 (PDT) 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 9034761541; Mon, 20 Jun 2022 13:00:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A314C3411B; Mon, 20 Jun 2022 13:00:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655730040; bh=8Qzn7BoD5ZQpLMt2i9GXYEkymXCq5HaMGEz1nkaAPTw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y5pJ0G3ek/0C4HR/lOeAz2w2zp6QrwIGAjhmHaSsX+hyVgXpZ1pjIHX8VQDdBAJem fn+WvAGOqnr6k0ljfyBl55O5wq09PaCkD2A+YufP5q9OVNcdvly517uaXwOS43fH0x cFKDSJnwR5lL76LPlvMdXdsnbUhhqyDBScgz0Fz0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sergey Shtylyov , Damien Le Moal , Sasha Levin Subject: [PATCH 5.10 14/84] ata: libata-core: fix NULL pointer deref in ata_host_alloc_pinfo() Date: Mon, 20 Jun 2022 14:50:37 +0200 Message-Id: <20220620124721.312866453@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220620124720.882450983@linuxfoundation.org> References: <20220620124720.882450983@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.7 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: Sergey Shtylyov [ Upstream commit bf476fe22aa1851bab4728e0c49025a6a0bea307 ] In an unlikely (and probably wrong?) case that the 'ppi' parameter of ata_host_alloc_pinfo() points to an array starting with a NULL pointer, there's going to be a kernel oops as the 'pi' local variable won't get reassigned from the initial value of NULL. Initialize 'pi' instead to '&ata_dummy_port_info' to fix the possible kernel oops for good... Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool. Signed-off-by: Sergey Shtylyov Signed-off-by: Damien Le Moal Signed-off-by: Sasha Levin --- drivers/ata/libata-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index f963a0a7da46..2402fa4d8aa5 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -5475,7 +5475,7 @@ struct ata_host *ata_host_alloc_pinfo(struct device *dev, const struct ata_port_info * const * ppi, int n_ports) { - const struct ata_port_info *pi; + const struct ata_port_info *pi = &ata_dummy_port_info; struct ata_host *host; int i, j; @@ -5483,7 +5483,7 @@ struct ata_host *ata_host_alloc_pinfo(struct device *dev, if (!host) return NULL; - for (i = 0, j = 0, pi = NULL; i < host->n_ports; i++) { + for (i = 0, j = 0; i < host->n_ports; i++) { struct ata_port *ap = host->ports[i]; if (ppi[j]) -- 2.35.1