From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDE67C4338F for ; Fri, 6 Aug 2021 08:49:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BFC8A60F59 for ; Fri, 6 Aug 2021 08:49:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240121AbhHFIuJ (ORCPT ); Fri, 6 Aug 2021 04:50:09 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:56136 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230119AbhHFIuI (ORCPT ); Fri, 6 Aug 2021 04:50:08 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 1764221D5F; Fri, 6 Aug 2021 08:49:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1628239792; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DqfZ0EX6qw3gb6dM2lfH7Nb6AA+OH0e+E9G+jYF9BHw=; b=frYV/bQnKs7zDi2yOQuN/PpHJjQhzBqEwf3O3i0NkHHeFuSeIUbh8eLIlr+MChuuI2FypM u6sFNkuxSz1NNEN5NRf3qbo2XDrbiF5WtzoN0sPCB+WsbWFl0fIV9OFH1I7fO1cGwUeiMy Jw0tnXkyXy83meW9hUx81wJNcgRsWcs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1628239792; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DqfZ0EX6qw3gb6dM2lfH7Nb6AA+OH0e+E9G+jYF9BHw=; b=7Hn+9p2g1RjearRiMl0K5dv5SdOFBTy03cHwZQEY57Huno39aJWMuV+q6ME91lPbYZ6GTD UU/s0xexWvRPmbAA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 05F9013A62; Fri, 6 Aug 2021 08:49:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ZhUxAbD3DGEEZgAAMHmgww (envelope-from ); Fri, 06 Aug 2021 08:49:52 +0000 Subject: Re: [PATCH v2 1/9] libata: fix ata_host_alloc_pinfo() To: Damien Le Moal , Jens Axboe , linux-block@vger.kernel.org, linux-ide@vger.kernel.org, "Martin K . Petersen" , linux-scsi@vger.kernel.org Cc: Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani References: <20210806074252.398482-1-damien.lemoal@wdc.com> <20210806074252.398482-2-damien.lemoal@wdc.com> From: Hannes Reinecke Message-ID: <82ac7a61-b8e7-2aea-00c2-e720f073930f@suse.de> Date: Fri, 6 Aug 2021 10:49:51 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210806074252.398482-2-damien.lemoal@wdc.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org On 8/6/21 9:42 AM, Damien Le Moal wrote: > Avoid a potential NULL pointer dereference by testing that the ATA port > info variable "pi". > > Reported-by: kernel test robot > Signed-off-by: Damien Le Moal > --- > drivers/ata/libata-core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c > index 61c762961ca8..ea8b91297f12 100644 > --- a/drivers/ata/libata-core.c > +++ b/drivers/ata/libata-core.c > @@ -5458,7 +5458,7 @@ struct ata_host *ata_host_alloc_pinfo(struct device *dev, > ap->link.flags |= pi->link_flags; > ap->ops = pi->port_ops; > > - if (!host->ops && (pi->port_ops != &ata_dummy_port_ops)) > + if (!host->ops && pi && pi->port_ops != &ata_dummy_port_ops) > host->ops = pi->port_ops; > } > > Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes Reinecke Kernel Storage Architect hare@suse.de +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer