Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp178969rwl; Tue, 4 Apr 2023 21:40:39 -0700 (PDT) X-Google-Smtp-Source: AKy350Z91/LNj+9oARXA8mCSndIT6D8bzARhEsCDyuYQS5q0aXbHLKzWOXflbjFYneVMiNaVjUwO X-Received: by 2002:aa7:dc19:0:b0:4fb:c66f:71c4 with SMTP id b25-20020aa7dc19000000b004fbc66f71c4mr227367edu.11.1680669639418; Tue, 04 Apr 2023 21:40:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680669639; cv=none; d=google.com; s=arc-20160816; b=owGOPRS6zvAvnJaTEW1+wIj9HEn20cbopxikoOm3vMZ5jpfnFa78Q1F+MdRRUjzY+u pVSXWtR5aJ/EWm9VKsb0SamLTNHBPfFAK1IZOehfO19H7/RXKlO5amDJt9EvuVRygPFZ iObLQAoB0AI2XcQhEEWMOwP/YDCQqE5RvOknsOfzhSl+5oAzw+yyFSZI39/Pck7ylj6N 2cElpozgIkufm3CKNQHRHKB35kO1DvMOh+ff+bkt3efxeVjJbLT9ojNPaGEmWnKTiOeb twh2BZY4tKvQi2yZoWq5/YLQYPqj1RkPKW9XE3sdOBbXU7VoKN/G5jCtfHDMN7c9eWj6 FStg== 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 :content-language:references:cc:to:subject:from:user-agent :mime-version:date:message-id; bh=u7zt5g5v7UuIgpYKCHNjRVPvN3Pw2+3x/VFCJ1jYcn4=; b=04wzuZCDz7X5OI8q6IjAX8vqzUgmgdCI3v/NipdOenz9I0R63GKdwJ3u8gBZVgjDwt xbZhKu84dOOJ7bvq8WkAresZCh0JMQZBDkDTifHRRQnkhh/iqUE/z6mrFme6JB2AMsr3 JkQ1CCJFxMEPf1SbOGhV2iXCoW9vzUeyVXqMOgbeNTGyUox3w7RBhMxWkvvU36R7h+7c +UH0kwW77q+zhjQ0clKdiNHJmlyzvbOz/ERXV4Wb9tUHKwpYXlt8W9BCJcwzuGTzvaDf VuQ1FLgsHUiH436RDtGNiTtn/baVzUvgNdrfSWqMW52B8f+FkHqvGA3fyj35ZJAa7d8O e1UQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=sangfor.com.cn Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i26-20020aa7c71a000000b00501e2c6548csi2570360edq.489.2023.04.04.21.39.47; Tue, 04 Apr 2023 21:40:39 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=sangfor.com.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236872AbjDEE1m (ORCPT + 99 others); Wed, 5 Apr 2023 00:27:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236840AbjDEE1j (ORCPT ); Wed, 5 Apr 2023 00:27:39 -0400 Received: from mail-m11880.qiye.163.com (mail-m11880.qiye.163.com [115.236.118.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06E601990; Tue, 4 Apr 2023 21:27:35 -0700 (PDT) Received: from [IPV6:240e:3b7:3279:cf80:7d5f:ad4:6d39:def4] (unknown [IPV6:240e:3b7:3279:cf80:7d5f:ad4:6d39:def4]) by mail-m11880.qiye.163.com (Hmail) with ESMTPA id 5F10320368; Wed, 5 Apr 2023 12:27:32 +0800 (CST) Message-ID: Date: Wed, 5 Apr 2023 12:27:32 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 From: Ding Hui Subject: Re: [PATCH] scsi: ses: Handle enclosure with just a primary component gracefully To: jejb@linux.ibm.com, Jiri Kosina , "Martin K. Petersen" Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Michal Kolar References: Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVkZTx4dVh9NHUsdHk5OTxlKGFUTARMWGhIXJBQOD1 lXWRgSC1lBWUlPSx5BSBlMQUhJTEJBGB1DS0FMH04dQRofT0FNH0hCQR8eHU9ZV1kWGg8SFR0UWU FZT0tIVUpKS0hKTFVKS0tVS1kG X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6K1E6OTo6Mz0RDj4qDRE#PwsY Vk0aFC1VSlVKTUNLTU1DQ05JQk9DVTMWGhIXVR8SFRwTDhI7CBoVHB0UCVUYFBZVGBVFWVdZEgtZ QVlJT0seQUgZTEFISUxCQRgdQ0tBTB9OHUEaH09BTR9IQkEfHh1PWVdZCAFZQUhKTkk3Bg++ X-HM-Tid: 0a874fab81702eb6kusn5f10320368 X-HM-MType: 1 X-Spam-Status: No, score=-1.9 required=5.0 tests=NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/4/5 4:26, James Bottomley wrote: > On Tue, 2023-04-04 at 21:23 +0200, Jiri Kosina wrote: >> From: Jiri Kosina >> >> This reverts 3fe97ff3d9493 ("scsi: ses: Don't attach if enclosure has >> no components") and introduces proper handling of case where there >> are no detected secondary components, but primary component >> (enumerated in num_enclosures) does exist. That fix was originally >> proposed by Ding Hui . > > I think everything in here looks fine except this: > >> --- a/drivers/scsi/ses.c >> +++ b/drivers/scsi/ses.c >> @@ -509,9 +509,6 @@ static int ses_enclosure_find_by_addr(struct >> enclosure_device *edev, >>         int i; >>         struct ses_component *scomp; >> >> -       if (!edev->component[0].scratch) >> -               return 0; >> - >>         for (i = 0; i < edev->components; i++) { >>                 scomp = edev->component[i].scratch; >>                 if (scomp->addr != efd->addr) > > If you remove the check, then scomp could be NULL here and we'll oops > on scomp->addr. I think we should remove the check, because the edev->components represented the effectiveness of array pointers, so we need check edev->components firstly instead of checking edev->component[0].scratch, if edev->components is 0, we won't enter the for loop, don't worry about dereference scomp. > > Regards, > > James > > -- Thanks, -dinghui