Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3600831rdg; Tue, 17 Oct 2023 23:21:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGhE4unqqSotVw1a7jYL0fHdJyIzz8/VjNqHAZ8GZHluVlmiVlIDA+eDolVFlKa+voIsHw0 X-Received: by 2002:a05:6870:7d01:b0:1e9:cde8:6db0 with SMTP id os1-20020a0568707d0100b001e9cde86db0mr4659965oab.50.1697610104656; Tue, 17 Oct 2023 23:21:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697610104; cv=none; d=google.com; s=arc-20160816; b=PHo13xa6eCE/YDBDYsViCyYe1PqiOAkkk5tM8iZfFL87quTGVdP+sq381Qv0SlzEXB fpMa7vjTn+lvwEa2l/FFOqDoLqqIbAggzelAE4dJM6/UGWIPc4SaHUrZz3e4Rp66HhCa pBF1nzoCnTg3j/k7v+ishMlMyB/amjK8D46mueLvDlfRWzZz0JLcbvCmFzX5ooAAjd9g CaTauj13m2ltL+YoTdQLlsecPOy4B6Q0o+5G6guXSbw7rZjekl/ZNyAQ377XtaiOmL40 vFemzBbsQMfQheDY96vE5PJwGM4wwJOzgoA+FqKN4vuCEXVfaTUY0q6cmIW0rzVSSo/p a6ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:dkim-signature; bh=fK8vTxNBtgmrxIGJRNeEWLKZBMWZ2IC18VS24m3CYAw=; fh=rphZG+7tMw8I3C78+zcMQu40WbmY96+tnmgzmNOblUQ=; b=OXUOyuXrNJit5WuV8ybHnfVolwZXB3sR1PabvPXN6PJJtEXS68ejMORX2JlbFjhhK/ oJh1Pxl7Aj36lhm56k4WsOiffUDilz11npL9tPHJsygnmGr45p1FNddO9rX7fQIQBY3M tJcN6dGeodorTU5sSluVTujUNPtaO769d89whPRwBaDoK9EhU439/KJRcnVkJnueUa9O UC12kDduR5iXkVwODlSC8qYVHNNCjgRCb0R/qLJVbVMheEEGvpZVlyabg9UnjDHNat4/ Y+Mk1WxGpxwPAFkKU6tUkcAHC6E5o8TNJM6at7A98yfznnQyADIqgTtxVMvDpNsfPesy Uaug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=U6xrjCg+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id j184-20020a638bc1000000b0054fbd904b6dsi1474070pge.500.2023.10.17.23.21.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 23:21:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=U6xrjCg+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 5F88C8129ADA; Tue, 17 Oct 2023 23:21:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229669AbjJRGVk (ORCPT + 99 others); Wed, 18 Oct 2023 02:21:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234909AbjJRGVV (ORCPT ); Wed, 18 Oct 2023 02:21:21 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EAF63245; Tue, 17 Oct 2023 23:19:14 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE1BDC433C8; Wed, 18 Oct 2023 06:19:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697609953; bh=IH6EcdEgGPUVYzbdSUQ9rvp1MDv+kNGyVu7PhFgRdoM=; h=Date:Subject:To:References:From:In-Reply-To:From; b=U6xrjCg+DAIZLu3YLViHoKLLRjPcep7yYsGCnLeVBqbAnWhLL5JNXQUkob2SoWmVd dARotGYrICb63g7QBD+3HLRqjzmS4wvp4ZxA2x42G1a9CuCy+gBMOfUsxs34l4MS1g aVSslStjDoBypHWs8LPaaVV6fblihup70boMV4Y2ASpCo+l3y7KJbxWh12WfO+CO/c 0WEqfQXmZ10AN33FXPVSudz50lvqsZpgaufo17Pva2tP7xC9pZGExbwgffN0uYz3/5 MYlXSnsi0wNBS+MV0v5YpC5GI0JnZowECt6INKlzt4HJ9tCe8p0WbYrfeAZhNwle0y W2mvztS839Rng== Message-ID: Date: Wed, 18 Oct 2023 15:19:08 +0900 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] pata_lagacy: Handle failed ATA timing computation in opti82c46x_set_piomode Content-Language: en-US To: Haonan Li , Sergey Shtylyov , linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org References: <1a0c4378-29b2-43b4-982b-0d92dfb8ed4f@kernel.org> <20231018005220.2551586-1-lihaonan1105@gmail.com> From: Damien Le Moal Organization: Western Digital Research In-Reply-To: <20231018005220.2551586-1-lihaonan1105@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 17 Oct 2023 23:21:43 -0700 (PDT) On 10/18/23 09:52, Haonan Li wrote: > The function opti82c46x_set_piomode utilizes the ata_timing_compute() > to determine the appropriate ATA timings for a given device. However, > in certain conditions where the ata_timing_find_mode() function does > not find a valid mode, ata_timing_compute() returns an error (-EINVAL), > leaving the tp struct uninitialized. > > This patch checks the return value of ata_timing_compute() and print > err message. This avoids any potential use of uninitialized `tp` > struct in the opti82c46x_set_piomode function. > > Signed-off-by: Haonan Li Please do not send patches in reply to something else. Also, this is a v2 of a previous patch so the patch title prefix should indicate that and a change log should be present after the "---" below. > --- > drivers/ata/pata_legacy.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/drivers/ata/pata_legacy.c b/drivers/ata/pata_legacy.c > index 448a511cbc17..3c7163f97aaf 100644 > --- a/drivers/ata/pata_legacy.c > +++ b/drivers/ata/pata_legacy.c > @@ -579,12 +579,19 @@ static void opti82c46x_set_piomode(struct ata_port *ap, struct ata_device *adev) > clock = 1000000000 / khz[sysclk]; > > /* Get the timing data in cycles */ > - ata_timing_compute(adev, adev->pio_mode, &t, clock, 1000); > + if (ata_timing_compute(adev, adev->pio_mode, &t, clock, 1000)) { > + dev_err(ap->dev, "adev: unknown mode %d\n", adev->pio_mode); > + return; > + } > > /* Setup timing is shared */ > if (pair) { > struct ata_timing tp; > - ata_timing_compute(pair, pair->pio_mode, &tp, clock, 1000); > + > + if (ata_timing_compute(pair, pair->pio_mode, &tp, clock, 1000)) { > + dev_err(ap->dev, "pair: unknown mode %d\n", pair->pio_mode); > + return; > + } > > ata_timing_merge(&t, &tp, &t, ATA_TIMING_SETUP); > } -- Damien Le Moal Western Digital Research