Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3974733rdg; Wed, 18 Oct 2023 11:01:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHTd4aSnNb8p7tzCLD21hCVLqcZPAB1awJFFl3FkOxgzYU/aHRudO3VpIvJOiGrbxXQxQ50 X-Received: by 2002:a05:6a00:2d91:b0:690:c306:151a with SMTP id fb17-20020a056a002d9100b00690c306151amr6698084pfb.0.1697652108370; Wed, 18 Oct 2023 11:01:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697652108; cv=none; d=google.com; s=arc-20160816; b=t75Dox1EvMQdzmSF30ztrXLNstU6jJ01IWe5JGvUsmzeOMUYmO4xU45FUnxKS3Ek15 3gbaZdHBI3u4KmeiYmdzmcOFau1w6znPiW8lMpispeXEbvAHAi7mf1i7VOsO9xdoj1Nf jUKy1knNrHb/lnbDIgdcP6wemE+fK5u4aeLhD6ZYEiZfrRJPRS2HdnCMu16HjwCh+fhT DAaSsZ7fFLEEi/kFRP7cqFDQtYBH3frhxb3djOFhOSHExwY87Cu1M1vCihorn3XFLwCP 2EOi3QabNiZCPH55VEpgA6sTrr6d9YqWipQzWrsfTlePWB1U/i2gIvxz2pRIMvV/uumi FOjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=BlNVWCi4tE73KJBUGhTGPmq/A6sZ0EfC9I/MgZZhxjI=; fh=YHDi7/TPOhZXIKfCcO27WoIufc7A+7V4MIfMVVZvo+0=; b=wsjS4ThnmjmA4TOILARJTOXGr2szNg4ev6gUVWrwqRyv1uPCyNisqgTatebZnWD2RH A5qBrBPdexplgd1OS3jXZOyPvNU+6/cqI5pzh/uCbiIJaLvu7LU6FTTuOXnWvgZ1CUPI 6O4h5p6d9fnuI1re7rEk+XbVMykySVOqSuna+XMrkqRLWFDgtzRfcGk2gyVDGnBScTlK +evxnLfVT/O3JYjMCa8Y6lCGJQyzA5/wJzZ1iGQ3EAtx31WciyfNMwJ1dMlvUWlJlEIB pUXMVA8RQ8HsAe8JiCPPd109Yw0BNhz9Nc96uHRPpYNkm+SyqtTm4g/dnpHkI2oueg01 Eccg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Ivo44lRY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id e10-20020aa7980a000000b0069341622984si4393132pfl.147.2023.10.18.11.01.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 11:01:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Ivo44lRY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id BBDB680763E8; Wed, 18 Oct 2023 11:01:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232681AbjJRSAP (ORCPT + 99 others); Wed, 18 Oct 2023 14:00:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232333AbjJRSAA (ORCPT ); Wed, 18 Oct 2023 14:00:00 -0400 Received: from mail-yw1-x1136.google.com (mail-yw1-x1136.google.com [IPv6:2607:f8b0:4864:20::1136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2AEC1705; Wed, 18 Oct 2023 10:59:32 -0700 (PDT) Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-5a7b92cd0ccso89023377b3.1; Wed, 18 Oct 2023 10:59:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697651971; x=1698256771; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=BlNVWCi4tE73KJBUGhTGPmq/A6sZ0EfC9I/MgZZhxjI=; b=Ivo44lRY4SQth2GmoEFWR1n9WqSv5s+EVSv4Es1Q6RoNe1JId2iytw7Jv0ReRQCcYz AvSHiMsKel0FFRfW6Dnx5Fcu4pDCLYf9iSMh9mNJIvxPbEPYHdseDBI+JjE1g41bW+A2 L7PFnoM2CbXybZfc+NWB4AXzRrR8lXbl6qyoGgXzqGNaj2rLo56any2oQD1BZa1l0PVI yGl83XQiUsLeHBNa/ZK2I6QumPeXeqmMAkmKyDReFlFwzu7MFWZ/KnXg327Gu3p0gQ6V NuVPxlK+gp9ADR4+IjLbEHcHPmPc8PdTTGdzupSzfAP4bS6BD83phz9wlj0YuxKTxl+M VQGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697651971; x=1698256771; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BlNVWCi4tE73KJBUGhTGPmq/A6sZ0EfC9I/MgZZhxjI=; b=NNtRaSCgKexKwS3Di6u+HmP3tnH0dsdIJn9kLDsNFMxGycBVzaJW2oW31D0ADfG7BG Tmv18Re1rfde+yAyeTXtu9h5WMuJglTXCL/70Bvt/J3YrASqMT6VDhiz+RqI5qTLFm9t YaP8mCwTQd3OZ/SsoDZQIaMU5ZGwuEu1EBFSuAJcNEZi+fZE2wuikJD2CJX0Ev8/t2IR GJ0EXmlbKoJhqvSK/1pWrpnmMnruDWF8+GvCCQiqWTRorrGxjW4o6M2qXMWgVNaPrj9D m/ekLcYOyNDgFpwjZEklkD540uz7VOQrHaZHu6sZO0/9Gs0FGGTQzX1o5Gm9DQA2gPuC cJaA== X-Gm-Message-State: AOJu0YxA2U/2zcayiQugMSYxa2deKcbjaAAJJ6LA+V6Wy7CKsgnvY+T4 vKj7Sh3fTj1B4gx+c+HjJSs/JKCwhjzuXyGuzUM= X-Received: by 2002:a0d:cc04:0:b0:5a8:277f:b378 with SMTP id o4-20020a0dcc04000000b005a8277fb378mr15878ywd.1.1697651971126; Wed, 18 Oct 2023 10:59:31 -0700 (PDT) MIME-Version: 1.0 References: <1a0c4378-29b2-43b4-982b-0d92dfb8ed4f@kernel.org> <20231018005220.2551586-1-lihaonan1105@gmail.com> <8332cf70-1451-6903-562f-1d16e4c243ae@omp.ru> In-Reply-To: <8332cf70-1451-6903-562f-1d16e4c243ae@omp.ru> From: Haonan Li Date: Wed, 18 Oct 2023 10:59:13 -0700 Message-ID: Subject: Re: [PATCH] pata_lagacy: Handle failed ATA timing computation in opti82c46x_set_piomode To: Sergey Shtylyov Cc: Damien Le Moal , linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email 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 (pete.vger.email [0.0.0.0]); Wed, 18 Oct 2023 11:01:14 -0700 (PDT) Hello Sergey, Thank you for pointing that out. My main concern was the potential for ata_timing_find_mode() to return NULL, causing ata_timing_compute() to return -EINVAL. While this might be rare, I thought it would be safer to handle such cases. However, if the common practice in drivers/ata/ is to ignore the result of ata_timing_compute(), let's drop the patch as needed. Thank you for your time and feedback. Best, Haonan On Wed, Oct 18, 2023 at 10:15=E2=80=AFAM Sergey Shtylyov wrote: > > Hello! > > On 10/18/23 3:52 AM, 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. > > Looks like it's very common to ignore the result of ata_timing_compute= () > in drivers/ata/... > Mind sharing the "certain conditions"? :-) I don't think the set_piomo= de() > method can be called by libata itself with an unsupported xfer mode... > > > 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 > [...] > > Reviewed-by: Sergey Shtylyov > > MBR, Sergey