Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp485980pxf; Thu, 18 Mar 2021 05:34:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJys76QuQdJacmnvlXkFxze0Ize6kQZXgB/3M39pS1hfOP+mgm1nvR0vNd+T2IjmUhrVh4WU X-Received: by 2002:a17:906:4e91:: with SMTP id v17mr40585794eju.331.1616070852946; Thu, 18 Mar 2021 05:34:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616070852; cv=none; d=google.com; s=arc-20160816; b=JNDIeD2+ix+KDPhjql7nBr5kQUkUEJfEdABEHvhMONMfVCikbpPE605Y9NduhpR0dG KbwHj56kZ2SI/jscIP9M7cEOKNrnM8mmdNvysNrhB9U+0hOasCFwRLenMbiRBewi+w3x 0peQ7D0iS9SNxWvRLc7CM7c863xt2Pk0VC36HxSepxXe/B+smUSjR/yVdjJyl0OZfyps bPs0iPZqt7i2VzpZsq4ZwNwtBl/OjUUUxkwf+44BAND3b3ALebtoRl4DizBPFwidkm4+ 7Uj8zDofd9FEdFOr6wVa5z08o/wzFOt4EI+/hm3pclmi0D+rmGuBbxxXUWdb0a5C/n+s xm7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=w4WbbmRHwAdL9N9Ihao72jFINYFO8ITTd62kvPQr4DQ=; b=vxXfcQRShNEsZEp8owQoCerqHLUwNKRxvqBmQpgCg5Km2uRjYgIdpuUkErsyQ8qiD1 tkLlnbd2Gvf+EzbmltZT3qPHX3niyufqLq91iTZxdBdk/DiAtx41lThvZ1VEFc91LyUx SPGNYtmNDk9tpGc8gLmsBl8/UWtvP4aG6/sz8miJTbkR0LHV+NAHol+inCYgH9iDsnts SZ9X6wBWZdQnDZ9lrWxiYlHyCv4QMoFNJ8MP1Hi+RNGK85B0n/bfEduBFodf7t0mfW73 y0Wcei5eE7XkOAiB4JsuC+rWU6kHwzjV33dt47TB1C3gnCLEf6xAk+RLBOkjZQpaEGOI FtJA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=sangfor.com.cn Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i6si1439185ejz.383.2021.03.18.05.33.49; Thu, 18 Mar 2021 05:34:12 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=sangfor.com.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229745AbhCRMcW (ORCPT + 99 others); Thu, 18 Mar 2021 08:32:22 -0400 Received: from mail-m17635.qiye.163.com ([59.111.176.35]:39232 "EHLO mail-m17635.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229943AbhCRMbz (ORCPT ); Thu, 18 Mar 2021 08:31:55 -0400 Received: from [0.0.0.0] (unknown [14.154.29.151]) by mail-m17635.qiye.163.com (Hmail) with ESMTPA id C37BD400325; Thu, 18 Mar 2021 20:31:49 +0800 (CST) Subject: Re: [PATCH] scsi: ses: Fix crash caused by kfree an invalid pointer To: jejb@linux.ibm.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, stable References: <20201128122302.9490-1-dinghui@sangfor.com.cn> From: Ding Hui Message-ID: <34c15b48-c131-abd5-d4a5-1c273d25c0bf@sangfor.com.cn> Date: Thu, 18 Mar 2021 20:31:45 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZS1VLWVdZKFlBSE83V1ktWUFJV1kPCR oVCBIfWUFZTUNIGhlJGBgaHUNCVkpNSk1LTEtMSktLQkpVEwETFhoSFyQUDg9ZV1kWGg8SFR0UWU FZT0tIVUpKS0hKTFVLWQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Kzo6Lhw*Vj8SLU4yKAEzSxIO ShEKFEJVSlVKTUpNS0xLTEpLT0lNVTMWGhIXVR8SFRwTDhI7CBoVHB0UCVUYFBZVGBVFWVdZEgtZ QVlKT1VKTk9VSUJVSk5KWVdZCAFZQUlDTU43Bg++ X-HM-Tid: 0a7845521313d991kuwsc37bd400325 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/11/29 7:27, James Bottomley wrote: > ---8>8>8><8<8<8-------- > From: James Bottomley > Subject: [PATCH] scsi: ses: don't attach if enclosure has no components > > An enclosure with no components can't usefully be operated by the > driver (since effectively it has nothing to manage), so report the > problem and don't attach. Not attaching also fixes an oops which > could occur if the driver tries to manage a zero component enclosure. > > Reported-by: Ding Hui > Cc: stable@vger.kernel.org > Signed-off-by: James Bottomley > --- > drivers/scsi/ses.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c > index c2afba2a5414..9624298b9c89 100644 > --- a/drivers/scsi/ses.c > +++ b/drivers/scsi/ses.c > @@ -690,6 +690,11 @@ static int ses_intf_add(struct device *cdev, > type_ptr[0] == ENCLOSURE_COMPONENT_ARRAY_DEVICE) > components += type_ptr[1]; > } > + if (components == 0) { > + sdev_printk(KERN_ERR, sdev, "enclosure has no enumerated components\n"); > + goto err_free; > + } > + > ses_dev->page1 = buf; > ses_dev->page1_len = len; > buf = NULL; > Can I ask you to resubmit your patch ("scsi: ses: don't attach if enclosure has no components") to kernel, thanks -- Thanks, - Ding Hui