Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1201934lqa; Mon, 29 Apr 2024 00:51:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVHP7SWi2GLn/ILqxrS6+nRcSNQdRJq/BKENSJ4w16WZ6QlTnFXQfsk3svd+8ESZxDhsnJNlEQMri6J3InK20/TqsxcJ5bnDMcGiVbWLA== X-Google-Smtp-Source: AGHT+IEYvXLVWW4DJW3LdoKIYMHK1RW44XCsUZ1jzZ9Jx5OBC9oiKHrrObk/xOTmDUo7xqIsVVDG X-Received: by 2002:a17:902:b707:b0:1ea:f921:61db with SMTP id d7-20020a170902b70700b001eaf92161dbmr7908754pls.58.1714377072810; Mon, 29 Apr 2024 00:51:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714377072; cv=pass; d=google.com; s=arc-20160816; b=u9PI0ZazwyPGwx6ym1AICf356xPmBAdqa1nzTzY6y2jHMEepLnkY9A3mhHeX4teGHK R3e36BRsaICLoA3xLPgvjP9d10v0NXIx33XmOVbm01aEbvpPswdxZQvkNyCknKLx7m6b Rb4ahwoX0AdbXqDyxi5kbWZTpugLraag/dno26moYLrwZD2fK+Xl5myIdPdameHnxJky MVa/UBhm/67zl4qR+0kIn0qpnNc5kbUpgTfg2PqBJT0G0g9wPS1a0ZFZNwzREfe4XrvF 3kp2ZC2Rwr2jUhppGVwG/whNEhZrCRnYgtfb7mbVZg3GORN6YTnaqIqS2NSl3/c5KoSg lG3g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:in-reply-to:from :content-language:subject:references:cc:to:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=PwgbfZv/QKuas8oXbIWGJWatANQIrG/1UIMV8+ZSv1Y=; fh=ysNCaaKxQFG1oTrrlMl6YEWux33IqDROR2Ld3JuvYco=; b=HdWi/hSXyjhQ5t5bLPS8jFZZ/HBtzJfgivK5MNZgcqFRyyXM1KIJVdUGOPqm9y0Z/3 uslQEZihUbaFDGhT2DYNqZOQrNg7sDbtOl99b52a6pBuhEf0K60oY9JB/ZEx2OTYsBij sOZ7cCo4HV8io3BqstEfkctTbTLdM4H8HIF/jpRq7P3zDJPzh6Gkd2/NEHlxQPisOq9l GV6isuh83bRtloFS1GMqN+iBDtijhm6N3A/10zpHxODb3HFo6R7DKWH6rp0kALm0lxAr hXR2PlWonVU4WNwg0TG1SgTokNGuT2HrTDs3C5XCLedJdiZfuFr6U74bJC2zHu5HSn6Y lq1Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@web.de header.s=s29768273 header.b=FarfbKJu; arc=pass (i=1 spf=pass spfdomain=web.de dkim=pass dkdomain=web.de dmarc=pass fromdomain=web.de); spf=pass (google.com: domain of linux-kernel+bounces-161876-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161876-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=web.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id p7-20020a1709028a8700b001e421f98ec0si15801515plo.91.2024.04.29.00.51.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 00:51:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-161876-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@web.de header.s=s29768273 header.b=FarfbKJu; arc=pass (i=1 spf=pass spfdomain=web.de dkim=pass dkdomain=web.de dmarc=pass fromdomain=web.de); spf=pass (google.com: domain of linux-kernel+bounces-161876-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161876-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=web.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7479B2820BE for ; Mon, 29 Apr 2024 07:51:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 660C215E8B; Mon, 29 Apr 2024 07:51:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=web.de header.i=markus.elfring@web.de header.b="FarfbKJu" Received: from mout.web.de (mout.web.de [217.72.192.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B06B814A8D; Mon, 29 Apr 2024 07:50:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.72.192.78 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714377062; cv=none; b=bHUh8h5xyIHKAv5iTXvBbRQE5+CtqXYTHYSym2dsVdpKEXya3Fau7hZNjCAB2TLEvaCl0LWgYGPPeQGmDmnAD3g5DUC/EGtgSKI9m44z0vURuunaYFntCaMbbHz+xBxzrYU+PmcsldzQLXst5ZzX+2nZ1AgzU8hOSb0aCYdo1IY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714377062; c=relaxed/simple; bh=o3lSfrItv9/X+b/XFKMfQD5nbXMPoTZ50KGLPNc6OGE=; h=Message-ID:Date:MIME-Version:To:Cc:References:Subject:From: In-Reply-To:Content-Type; b=l1nB9geywAR8I+qIyWvFgVngyFR4fyHMD6O/X6Fmir6W/kbUh9kAEZ7XSUomDlIVTMQmBVeRUNNP5Al9OiR9/E/xK1zzJtBaOxoqvOnY/QozpE05QKSX8ukD9WWrvIwr+HLoDFOpeDTaj1hvKRymRfoYC5pnkXKo9vYaadfv794= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de; spf=pass smtp.mailfrom=web.de; dkim=pass (2048-bit key) header.d=web.de header.i=markus.elfring@web.de header.b=FarfbKJu; arc=none smtp.client-ip=217.72.192.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=web.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1714377037; x=1714981837; i=markus.elfring@web.de; bh=PwgbfZv/QKuas8oXbIWGJWatANQIrG/1UIMV8+ZSv1Y=; h=X-UI-Sender-Class:Message-ID:Date:MIME-Version:To:Cc:References: Subject:From:In-Reply-To:Content-Type:Content-Transfer-Encoding: cc:content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=FarfbKJupRCGXP0R8oQtmIYHvwMhx4ft5+v3MVRfBpzzZRKVotKNsM51gJc/YwVR ltfcT19nSkWwmVDrl2Xw90bxilKSxjrvGBLh9Ji3zZNPolljUaSb5egBp9jNCiGBx N43VQ87a6YmUxVGoiGTg+s8nJf4qOIVFFpFdW8irUvQZ7Dzp33SSFEZ4Szspca9Lb 0WzGnlJqJVq7J1zaiZue3riFEwJQWmPLZvO8jpfguvfLNJgfyjkqOZ0+EreLGT63W OFg7hSK3Yom0IWqyiZqaJVAMWw9Mcor/4f9H+SKMmGCBxnKs0nyKxXQWezHV5jVKD MPMhSbuV1uA3T/KeIg== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.85.95]) by smtp.web.de (mrweb105 [213.165.67.124]) with ESMTPSA (Nemesis) id 1Mo6Nt-1sTHxG36eB-00q8PB; Mon, 29 Apr 2024 09:50:37 +0200 Message-ID: <1df4e8d4-733f-43d9-a9d7-3764b6df7ed7@web.de> Date: Mon, 29 Apr 2024 09:50:36 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Li Zhijian , linux-cxl@vger.kernel.org, kernel-janitors@vger.kernel.org, Alison Schofield , Dan Williams , Dave Jiang , Davidlohr Bueso , Ira Weiny , Jonathan Cameron , Vishal Verma Cc: LKML References: <20240429013154.368118-1-lizhijian@fujitsu.com> Subject: Re: [PATCH 1/2] cxl/region: Fix potential invalid pointer dereference Content-Language: en-GB From: Markus Elfring In-Reply-To: <20240429013154.368118-1-lizhijian@fujitsu.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:/YgV0cA6lKGixm8+QuV2vBOSOM230psviYgQtCMgXsfzK+y0HVv NNnrBJriTCJRUoGnKcQNOEpO22Xg1cEfBZn6TbygF+fAexxqK8urnbC2mylPaocWLIH1tAk s6OWYF+JCmlEp8Z1E1RuSfGXj2xDbxySCoGip+a/p0YSfXzoELdoChrdTZa5lMbvaSifT2i Kkm1t/RtAiLLjl6OgNC3A== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:5AUYALFlqcs=;5IN+RQpPqc6kRVvvKWiU6Ggjxpw Tks4v5dEKYql2S9K/LSiubnVjaA89gOJRCsQ3CxVSMec1F157wgvZl8gcdH1g01WV8fGrDWp8 19kKNVKyhUxA0vZT7+mtOuOSPMLVaSFwlJz+2Q1mryG9tTyBtUaSG7ibhOCCc7a9uOkP9gUyc GKjOP4DeNBtmVBPHuG+HGCRUoXt1DNEPlL6YaSunFi8jodUF8L/L69lUG/xBr0avRkyUyQBLz MvGe3jzGef4UzPKwB+J9U7Hn7UsSczgkTQcv64VQdV7A1+vOWNCUgaIEgj3F6SVDV27QHYsXh +FjoJDUqLPO41CtGlRX3Eh1dQnLWoY/SlTIkmSWlNcSZX+9IAoeS2RMuDoefbLzEVt6+g2nqC lPDCcZ3xNENYMxnIlILc25WCD9pFRjXJ2olx2/f5fgHAYIl1n/+ijAfDKq5o6kXqUqL6x+1a/ aJ+4hl+dUH3u9zFr7FNQAFR+03ecBpythDE2/h4DEtRxVa+NghOHnW0BOuF7WvcqLit90d7V5 R2V8cEu2rg7zWJv1bRAV76rZfhQYafkGtjWWK190Ovc74eg7SM6G4MmgDqWxxuWJj4cYpHq6L 6W6cJUpJ02EvgvPXPGV3qtUYGJHXflpv+pIfnlAILVXycrqOUkdHr9PHWHKD2GzIUzV0/P+00 RfKNoWmiQWqFTdwbzOf6b0eW4JIHBetHCOk0Crd0Y/NeYcmk5oPX9BvhAxXsNgo5RvpgZ6LAH rh413SXfTRHE+XbNxs66eRGroq7Z0JJ9ykeG6WbEr90BeYyTYUBECnWZfTr9c/qG7EuLPIh2K UlShrw0Ppg93zthB4oCI4xecmzODj6/fZ3cnho8qIe6Z0= I would usually expect a corresponding cover letter for patch series. > construct_region() could return a PTR_ERR() which cannot be derefernced. I hope that a typo will be avoided in the last word of this sentence. > Moving the dereference behind the error checking to make sure the > pointer is valid. Please choose an imperative wording for an improved change description. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Do= cumentation/process/submitting-patches.rst?h=3Dv6.9-rc5#n94 =E2=80=A6 > +++ b/drivers/cxl/core/region.c > @@ -3086,10 +3086,9 @@ int cxl_add_to_region(struct cxl_port *root, stru= ct cxl_endpoint_decoder *cxled) > mutex_lock(&cxlrd->range_lock); > region_dev =3D device_find_child(&cxlrd->cxlsd.cxld.dev, hpa, > match_region_by_range); > - if (!region_dev) { > + if (!region_dev) > cxlr =3D construct_region(cxlrd, cxled); > - region_dev =3D &cxlr->dev; > - } else > + else > cxlr =3D to_cxl_region(region_dev); > mutex_unlock(&cxlrd->range_lock); I suggest to simplify such source code by using a conditional operator exp= ression. Regards, Markus