Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2812400pxb; Sat, 30 Jan 2021 15:57:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJzA8QgiAQnQIgAjRe+pXMiWIo4jSUe4U3NPG+baXzo7Osr1Zy9N/wxQzS9gmASaZRObjLM5 X-Received: by 2002:a17:906:780c:: with SMTP id u12mr10897504ejm.125.1612051067971; Sat, 30 Jan 2021 15:57:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612051067; cv=none; d=google.com; s=arc-20160816; b=M++u20L39xZsKFAB3wo6j7nWJDzfOE6TSQyEvbpyYQiSG/4m3wO9lO3ymW/JOXGSi0 ItgQfL6VfXLP04el838igSsciIl9MWw57M0NSGaZdmFZIpbS7IeitNr7H2fLatVDYAfe djwPblsdF0KJKNZun/7KSLrn2396SDbA59ZcygL5eGmlD4J1GoDhbdxGlzWOlHyfcIZF FbKR5IhUtcpSMaV4ZBX0aoiJ2f1lTBIOk+X4ZA15eEjcjiV4/4QtPiaph4jsyqAoVaft wD3dS0ahzHm52w0IU3TKRx2Lp1QBDvLmQIoBsVXYTsUc/v7MX03Scr+n76c6NYJloht0 kSPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=/7bS81IVu1JlzOqn6sxVl7PF7QPT/qamlj9psA4nrKw=; b=mwn5wuDDZ4v+mCTpK58EpxpzkMX4MqVs3pqzoSvNr1NGVepAalqevmUit0WGcm9JTs Ly5/J8fA1TTqNRYK8nOysZFRlHchLd2Jk9o2GvctSbejjNglXsh0gxYcrI1r6kt8epH3 ZSNBPfrbVDOb9RwV2Y8vy2EvVYsY0Q81E9aAQR96/tca8PHx0z8uxKlQZRJXwI0ppFRO W9lgvmwlCpyPB3qUjfUBPKZRDYroJrPCb5TSaW8xyQlbX0KgvimePMYA4JxXb8rwgds6 lv1k0IJ1KQv2NQZ5DfX3RpubXqWf3t5p1wpOEdlxnIsyPA7CXRJi9L/G4GuaExG1sogT O81w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=KakMFpmD; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l14si7463385ejr.33.2021.01.30.15.57.24; Sat, 30 Jan 2021 15:57:47 -0800 (PST) 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=pass header.i=@google.com header.s=20161025 header.b=KakMFpmD; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232547AbhA3X4V (ORCPT + 99 others); Sat, 30 Jan 2021 18:56:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232688AbhA3XxJ (ORCPT ); Sat, 30 Jan 2021 18:53:09 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCEDDC06178B for ; Sat, 30 Jan 2021 15:51:51 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id d2so2771813pjs.4 for ; Sat, 30 Jan 2021 15:51:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :mime-version; bh=/7bS81IVu1JlzOqn6sxVl7PF7QPT/qamlj9psA4nrKw=; b=KakMFpmDEnIJAfIkwgFElM2OuCuzZHKBG8btmmU1ofJKTS7yI0zo08pqWacZX46IFI 8fHWvBqPYFSupOKNtk43JJoG/x0xDILY1ny7YHyzKcQI/6v2eq+1+2sACm7zDjm9calq rah5jhD/eOqyjJnmkmMSpcrIa4Z4fOuHgRuowyV0XL+mnCr1BmkOz7ivyntQVH2EneOx iLG09O3UCbp8bUAmiA7k7GMVemtVjmTBSyL1T7IkifZ+NF1tJQKusqD8Mpl9Ru7GJRTO kL4WwHN7MMbiJL5NcAZkYBPC8h4+0dg3MVcVYtNOrdGtaqM3E3ELgyet8WY0yHGgx+NL TDeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:mime-version; bh=/7bS81IVu1JlzOqn6sxVl7PF7QPT/qamlj9psA4nrKw=; b=GsbWfdvZ0voz/0kzP28aJcEtacXEUJlrlWNErSzRyaWuWNlg1enbvHPrnd01AIsVlL HhPUgrf+gEzimZqlKVcMgBFHBxs9A9DyaGmhFnvYLSMpSaHW6A/p7yVLmBJaZL/XSP4R ahpqF7g2uhNo+i2iIyvCgLLS/ibI9PVSuUUXOHo8gigYw0pH3PNZ41NGV+2Rh5hm5fCs nsSRldAIUf2w5YE9OmKQcLTWbVNcvFd4exYw5xyz5g+vdejRA5irjyd0fHDM+HT5w74I t0RJU144RBQIlmlPjLb2GSHjpVh/plsgQRqorLg4AA2zZjdt5VGG65n1xl6TLXn7CDp+ h+Yw== X-Gm-Message-State: AOAM533o07PZnxcz+ccjw+O6za0sZ4BtL8TeKSYrP0qUwkYucT45HhVi 5gk4UtTrNZqf/dWVdh98eAcNAg== X-Received: by 2002:a17:902:9b90:b029:e0:6c0:df4f with SMTP id y16-20020a1709029b90b02900e006c0df4fmr11725622plp.60.1612050711168; Sat, 30 Jan 2021 15:51:51 -0800 (PST) Received: from [2620:15c:17:3:4a0f:cfff:fe51:6667] ([2620:15c:17:3:4a0f:cfff:fe51:6667]) by smtp.gmail.com with ESMTPSA id b62sm13308050pfg.58.2021.01.30.15.51.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Jan 2021 15:51:50 -0800 (PST) Date: Sat, 30 Jan 2021 15:51:49 -0800 (PST) From: David Rientjes To: Ben Widawsky cc: linux-cxl@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org, linux-pci@vger.kernel.org, Bjorn Helgaas , Chris Browy , Christoph Hellwig , Dan Williams , Ira Weiny , Jon Masters , Jonathan Cameron , Rafael Wysocki , Randy Dunlap , Vishal Verma , daniel.lll@alibaba-inc.com, "John Groves (jgroves)" , "Kelley, Sean V" Subject: Re: [PATCH 03/14] cxl/mem: Find device capabilities In-Reply-To: <20210130002438.1872527-4-ben.widawsky@intel.com> Message-ID: <234711bf-c03f-9aca-e0b5-ca677add3ea@google.com> References: <20210130002438.1872527-1-ben.widawsky@intel.com> <20210130002438.1872527-4-ben.widawsky@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 29 Jan 2021, Ben Widawsky wrote: > +static int cxl_mem_setup_mailbox(struct cxl_mem *cxlm) > +{ > + const int cap = cxl_read_mbox_reg32(cxlm, CXLDEV_MB_CAPS_OFFSET); > + > + cxlm->mbox.payload_size = > + 1 << CXL_GET_FIELD(cap, CXLDEV_MB_CAP_PAYLOAD_SIZE); > + > + /* 8.2.8.4.3 */ > + if (cxlm->mbox.payload_size < 256) { > + dev_err(&cxlm->pdev->dev, "Mailbox is too small (%zub)", > + cxlm->mbox.payload_size); > + return -ENXIO; > + } Any reason not to check cxlm->mbox.payload_size > (1 << 20) as well and return ENXIO if true?