Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1220809pxb; Thu, 21 Oct 2021 18:44:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXGUKPnEuvetTcL9bdSaBrvW/iezzak8PlOAkAH+3v95EvSVXqgNBWFMmsdQItEpyrqlw3 X-Received: by 2002:a17:906:2599:: with SMTP id m25mr11738690ejb.302.1634867066053; Thu, 21 Oct 2021 18:44:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634867066; cv=none; d=google.com; s=arc-20160816; b=ZVr7Mj35iiT1SRuseakAT9klsMYMMZVhOYUY5VDH3m0t8t88Qmi+3X+3JfCCPbVY// bQnSDoXJrSccJxVnEnwtr4VFbmYJObSoEBzE6OHZ0BTKQPDB7vLF7dvfxY4v+p/2Ba5S QvWSo5v11L97DUvMrzQp79rRdCgPhEPbXJCotP5a7KV56XLRr2xQ7h1MdrZcpds18Gv9 s6OJADRqs14yUQ0yzx5IJ4TQhYCrDhv276Gk6rUG4VkHrLM2vcpXi2mWuXAHMroMtNM0 NRKyN65YzwPlOAWaQYw6f3UzM7cxqaQ1B07eD3lur1DBGy1+Kf7mL5xU/suNdtB1BQE6 Oqsg== 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:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature :wdcironportexception:ironport-sdr:ironport-sdr:dkim-signature; bh=bGYJR3+ilEeSSron68H4Xmunu6qiUZEzajuLxHwxxeg=; b=KrikZ7VOVOZAZ0BsPoeiwpPUJZ25UiwlGpTk0EHFM5dPmLks1iRYBvY6EGw6+ZcxdY FJgJdLD2rhdF5Pf+cIMeGaP7e9ji5rCfPF1Gl58yNzRxvdsjV5PLsNrdFcvsNMe3kkPj IyMCn7miA/O1SX2dIChBH78Nc4yTM5p54M0vWHfyzTwodR3HBctIhZ6GPXOD3UDKfv2d XF7HsjZ/935NksiXTrRc1hnnxzpYobzDNYNPajqZ+MtAbOM8FcWuqOpXX6d3Dby9hyKt 2JrX124FkY5F2Bp41lVpjxpvjdYIwWwcUV4uO+eYPaKitfuvn12XRuI7usXeE7pgMl0N ly3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=MKUYj3Ff; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=qEHfXsqB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d26si8920714edx.561.2021.10.21.18.44.02; Thu, 21 Oct 2021 18:44:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=MKUYj3Ff; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=qEHfXsqB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231755AbhJVBoL (ORCPT + 99 others); Thu, 21 Oct 2021 21:44:11 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:52066 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230190AbhJVBoK (ORCPT ); Thu, 21 Oct 2021 21:44:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634866913; x=1666402913; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=Fb8PmAqzVEUvcNzAAPPpInPp8Q+wCVeIhNjeqX65G10=; b=MKUYj3FfCIJ8m4m4NOeRmcrEvrNthbyOva5456dJ6lKBGbE6orlpNA2+ U+o4deXtW7W0pO1s6yujgTs+llqdhbPa5qR9TuoRiE1vKJgpMrOaEEzr3 kwOTSINv0DuPI1l3jkL5H7Y8BhLRLZcrML2KmvxvR/OMsbWJNumUzaIZt sdu2im9d6zCi7i9634hwyGJAFfgUoLrbnK+OvXZc7qouGjjRkytvMbMSu YfeQS7EPNuBi2eTUsLoWNrThGmDH+1srfrdI3UouVcneaS9XvC0r1Zi8v XHO25JmkQYcKd/P8De3yhHZqtYh1LMLzelToxmGb6cOXSMp7CmOhMX6gf w==; X-IronPort-AV: E=Sophos;i="5.87,171,1631548800"; d="scan'208";a="183572328" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 09:41:53 +0800 IronPort-SDR: uEKbybdOxzxF8HIzcF8vGVGkXePFIuXHR90o1Jht2dsMxXQKfHCgGdx71BAM4ny8h8lupOMcHL /4FI9JG8ATqfAxZUp7IxQ1Yxzsp+n13g4RplcEgRFrIEPyZEt1JHJ9oVFWbuv3FkKaZ1QoQJRF B3pi3kv+snh1ZIzRP23s/4JgHPS+mKYneT3q2haa5plnqGEH+ofIHVj7P20GcHtmbo2Mrk0b8C iash9aP8V6NoB5e/9NdcVtbblHqmQjULzO3wqFPPl9W9NP9e4+6T++s528dE97ln5xo/PUTgpt S3WF8xi/bGgXqd43VNJ1GMNz Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Oct 2021 18:15:56 -0700 IronPort-SDR: GCygHQOAhKoOnTzjW6bpipuEgIuYaIJMoG6NvaYWdWskMWHAAvXm8iOySrk3IA9ZZIqPVkC6kV hE6BPW/C7NGdsv6UKekkRPYXCyE5GwqjEFi6hwHrsNulawjFl0qlxegJnkUYayJC74Qw06ot9i n9sY6EGuWQkMWYQcZB2m+aFn5Ojg8kAfgBFhc6qN4tMwzqoDo5+BZ5RuRZPfMoEAqI1vzu1F2s XlnRYPX/v9yx+Pz8Cv7OwvEoPft0H6jGurwf6N/Z2OfzPElPqpOKTE5z09akgZZoLF4yKjLuAn QFg= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Oct 2021 18:40:56 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Hb6WD3Fmyz1Rvlw for ; Thu, 21 Oct 2021 18:40:56 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :in-reply-to:organization:from:references:to:content-language :subject:user-agent:mime-version:date:message-id; s=dkim; t= 1634866855; x=1637458856; bh=Fb8PmAqzVEUvcNzAAPPpInPp8Q+wCVeIhNj eqX65G10=; b=qEHfXsqB9TKKHJQdqiXEnChbzMfeTVOloIFfLAsFItGgTEpqrg2 aUjxal4YL1grm6DgXuqAbH/xBpo71hQ9ssabNxGEwVfMQAWjqLH+WM05ZFzStTyF 6Sw1/9vpQ2fUXGoZbWfUeb5CUQcNNSs7vc//f0lVJSjusRow9NFUvbv/JG/IJ8oG 5wlMl0KOUq3XHL1qduokaJqYvBvHN8fWhgp6MvV6XUUflsX3aBIrI9rXZqF2KY7e +BBJzk7ze2OSMERlmQqqCt68C0eKGGIYZ5S+k13QYwWoeHsV6IoasiJowVokQDxG /CbC+re+0OQA3Oz5PGUqq4BVr2o86b5btxg== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id xK3eVAHcFWb8 for ; Thu, 21 Oct 2021 18:40:55 -0700 (PDT) Received: from [10.225.54.48] (unknown [10.225.54.48]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Hb6WC1N4Cz1RvTm; Thu, 21 Oct 2021 18:40:54 -0700 (PDT) Message-ID: <1fd2156d-1f96-6aa9-e528-0d83f12c840e@opensource.wdc.com> Date: Fri, 22 Oct 2021 10:40:53 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [PATCH] ata: sata_mv: Fix the return value of the probe function Content-Language: en-US To: Zheyu Ma Cc: Sergey Shtylyov , linux-ide@vger.kernel.org, Linux Kernel Mailing List References: <1634795836-1803-1-git-send-email-zheyuma97@gmail.com> <1d5064f6-0498-c78c-d98f-df7ca74e0a8d@opensource.wdc.com> From: Damien Le Moal Organization: Western Digital In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/10/21 20:23, Zheyu Ma wrote: > On Thu, Oct 21, 2021 at 6:38 PM Damien Le Moal > wrote: >> >> On 2021/10/21 17:37, Sergey Shtylyov wrote: >>> On 21.10.2021 8:57, Zheyu Ma wrote: >>> >>>> mv_init_host() propagates the value returned by mv_chip_id() which in turn >>>> gets propagated by mv_pci_init_one() and hits local_pci_probe(). >>>> >>>> During the process of driver probing, the probe function should return < 0 >>>> for failure, otherwise, the kernel will treat value > 0 as success. >>>> >>>> Signed-off-by: Zheyu Ma >>>> --- >>>> drivers/ata/sata_mv.c | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c >>>> index 9d86203e1e7a..7461fe078dd1 100644 >>>> --- a/drivers/ata/sata_mv.c >>>> +++ b/drivers/ata/sata_mv.c >>>> @@ -3897,7 +3897,7 @@ static int mv_chip_id(struct ata_host *host, unsigned int board_idx) >>>> >>>> default: >>>> dev_err(host->dev, "BUG: invalid board index %u\n", board_idx); >>>> - return 1; >>>> + return -ENODEV; >>> >>> Doesn't -EINVAL fit better here? >> >> If the error message is correct and this can only happen if there is a bug >> somewhere, I do not think the error code really matters much. The dev_err() >> should probably be changed to dev_alert() or even dev_crit() for this case. >> > > I don't think so, the error code does matter. If mv_chip_id() returns > 1 which eventually causes the probe function to return 1, then the > kernel will assume that the driver and the hardware match successfully > (even if that is not the case), which will cause the following error > if modprobe is called to remove the driver. What I meant is that -EINVAL or -ENODEV or any other proper error code do not really matter much since this error seems to happen only if there is something really wrong with the setup. "return 1" as it was definitely seems wrong. Given that the problem triggers with an invalid board_idx, -EINVAL seems more appropriate. But I would also change that message to dev_crit() or dev_alert() since this is a bug rather than a recoverable runtime error. Can you resend the patch with these changes ? > > [ 21.944486] general protection fault, probably for non-canonical > address 0xdffffc000000001b: 0000 [#1] PREEMPT SMP KASAN PTI > [ 21.945317] KASAN: null-ptr-deref in range > [0x00000000000000d8-0x00000000000000df] > [ 21.954442] Call Trace: > [ 21.954624] ? scsi_remove_host+0x32/0x660 > [ 21.954923] ? lockdep_hardirqs_on+0x7e/0x110 > [ 21.955240] ? _raw_spin_unlock_irqrestore+0x30/0x60 > [ 21.955634] ? mutex_lock_io_nested+0x60/0x60 > [ 21.956027] ? _raw_spin_unlock_irqrestore+0x41/0x60 > [ 21.956395] ? async_synchronize_cookie_domain+0x35f/0x4a0 > [ 21.956802] ? async_synchronize_full_domain+0x20/0x20 > [ 21.957179] ? lock_release+0x63f/0x8f0 > [ 21.957468] mutex_lock_nested+0x1b/0x30 > [ 21.957761] scsi_remove_host+0x32/0x660 > [ 21.958054] ata_host_detach+0x75d/0x830 > [ 21.958349] ata_pci_remove_one+0x3b/0x40 > [ 21.958649] pci_device_remove+0xa9/0x250 > [ 21.958949] ? pci_device_probe+0x7d0/0x7d0 > [ 21.959261] device_release_driver_internal+0x4f7/0x7a0 > [ 21.959647] driver_detach+0x1e8/0x2c0 > [ 21.959929] bus_remove_driver+0x134/0x290 > [ 21.960234] ? sysfs_remove_groups+0x97/0xb0 > [ 21.960552] driver_unregister+0x77/0xa0 > [ 21.960859] pci_unregister_driver+0x2c/0x1c0 > [ 21.961178] cleanup_module+0x15/0x28 [sata_mv] > > This is not the case if the correct error code is returned. > >>> >>> [...] >>> >>> MBR, Sergey >>> >> >> >> -- >> Damien Le Moal >> Western Digital Research > > Regards, > Zheyu Ma > -- Damien Le Moal Western Digital Research