From patchwork Tue Jan 2 13:10:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 184324 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4434054dyb; Tue, 2 Jan 2024 05:10:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IGQiE6LtieV+mcwcTefqvjYxHim8YtiZMA0hb6HRXryTIg6CUlmaMmtOIOMLdT9+TfvYil0 X-Received: by 2002:a05:6a21:6d92:b0:196:a808:7323 with SMTP id wl18-20020a056a216d9200b00196a8087323mr6146161pzb.104.1704201046508; Tue, 02 Jan 2024 05:10:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704201046; cv=none; d=google.com; s=arc-20160816; b=drlb3KzD1FrvaHBKggmDIvPbXYOlI09/62Mzn9U7ZaejZ+4u1uiplvCYILfV9QiFBr NQUDteTfQE90UnxCjaxEG+vv4TPONfDSAUgDJyuVHLBqjLYmrZIvQnjki53n4AWuonGs QidLdNHRJupW2G3fnkJWxmew0sJsuYSt9CWqXbHXbTdB9msm9saFIy15jJ7RWiZtbtJ9 H1Ol4iiLt65Ymn7cj7FgPCtgommX9Oq/89fH4laQ7ht/5rfaL6cioVXjELL7Hjmwue+E 8cBaJ09zSz+45YndFW/cdOP9h673Hb0MoLoqbGYx8qchr96FHmqkOOnzMrqcCNHlNkKi nq3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:subject:cc:to:from:date :dkim-signature; bh=uowTUjLxrj5pVd1k89+sk1irYGIPwxkoZlQeDZRpdQg=; fh=QgsB2KXrYN0XShAyGOnbg0ad15Zn1fYjo+YJLEzti6M=; b=EBhvnxxFij5EWTkZFT1ilP1QLm4zrSyPpajYP1Xt/Ji1h8H269u65Xd6GBxbDhc6Av 3PM6RERxJ4GwrE913BHf9hmFkDygNFxNsUBnZxAsUn03JxRbVkKv3EJ0VYgS0WoL3Tue flYH6MxP+RK/Kt7USTC0OZfvDeySx0eI5LXoYP/BDu3TnBPO1rN72mX39m8o5UGXHeUw kKEq7AJ8BthOZMrbXrOfPEaigXrv4NfNjR5uSZL1JFvmcJYPCAByOV1eeQl5DTk/W95g OfizGghR4RLUBMFsUDgzVFPapXqeOewjaSlXiPaGbniRhAh7NsfQnrZUVkMKFH28YFaO TpYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=figEQ5Yr; spf=pass (google.com: domain of linux-kernel+bounces-14377-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14377-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id ay42-20020a056a00302a00b006d9b4950515si14808150pfb.57.2024.01.02.05.10.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 05:10:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14377-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=figEQ5Yr; spf=pass (google.com: domain of linux-kernel+bounces-14377-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14377-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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 B1CDC283337 for ; Tue, 2 Jan 2024 13:10:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BB1F2FBF1; Tue, 2 Jan 2024 13:10:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="figEQ5Yr" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07AC0F9CC for ; Tue, 2 Jan 2024 13:10:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-40d2e56f3a6so53426445e9.1 for ; Tue, 02 Jan 2024 05:10:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704201025; x=1704805825; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=uowTUjLxrj5pVd1k89+sk1irYGIPwxkoZlQeDZRpdQg=; b=figEQ5Yr6raSC6f2I8z1J4R0+eNsuyrmweROQ79Hy0Rmy8aTENSYYXEWccGN4IeVZt Qrn/atllJPNTa0dJefjhccCWIcf+Qfg33MLULvjhGZm2DWjrSTWMVY/Z9vP7WUU5f/Nf lo4ArhPaD8kHp+y+w6e7gkEZ3WrC74h2cCAaVZgpOZhCx0D1F/iq+HtA2NjnpTbm/4RH 7FEhfAa2Px0Li3vD97TFuH4Ugaw+Rl8xDoSr7eG02YnGJOUk20nFoL9WKfpXXIyaFXi8 BgP/ROJNpn5hnzMxVq5hox1VG/dQEzV8Yo8FjbKrJj3s/Ndo/AIpVIwqegDhQxCcP+CA Cxdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704201025; x=1704805825; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uowTUjLxrj5pVd1k89+sk1irYGIPwxkoZlQeDZRpdQg=; b=RvmHq6wIIRHHgK0YgJzLdUAGZmWMSpVw2NZNFEZGcfYGIfN7dmwDU2R8l2e9LT18Kw emtdzI5PqlJyLba+r8U6or1T7L1W575/m0dETov2rEGpcMYIUtBmRiSoaTaamwxGsj5I QREQmaDh/tNBHYN1dpifPfESvvuj08pdXIkruvdclQUrDyyE/0vRICOooQ7yRO18ItFy jy3c4i4Y+VdDpQEFz5c7KPpTFaYg4v6gY6Fmho4RNcGk9pQotMxXorGivwmBao6QjpFI NQt901YAsqmbxXuf9Qg0/5NgYGmEjOt9odvJxcK2IbAMEas51252et5zqKoaVTgpwA9a yKUw== X-Gm-Message-State: AOJu0YypQqj00z9VfhwEcFFefc4nlsi4s6L2y+x7D4s9HTLh5RIAG6+A 5Fxd1FJkeDdNNfT9U5bYIzNaZTM1UDWekg== X-Received: by 2002:a05:600c:998:b0:40c:6c8e:8b7c with SMTP id w24-20020a05600c099800b0040c6c8e8b7cmr8100998wmp.55.1704201025149; Tue, 02 Jan 2024 05:10:25 -0800 (PST) Received: from localhost ([102.140.209.237]) by smtp.gmail.com with ESMTPSA id ay23-20020a05600c1e1700b0040d8d11bf63sm1884557wmb.41.2024.01.02.05.10.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 05:10:24 -0800 (PST) Date: Tue, 2 Jan 2024 16:10:21 +0300 From: Dan Carpenter To: Abhijit Gangurde Cc: Nipun Gupta , Nikhil Agarwal , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH v2 1/2] cdx: call of_node_put() on error path Message-ID: <2e66efc4-a13a-4774-8c9d-763455fe4834@moroto.mountain> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786984316272372022 X-GMAIL-MSGID: 1786984316272372022 Add a missing call to of_node_put(np) on error. There was a second error path where "np" was NULL, but that situation is impossible. The for_each_compatible_node() loop iterator is always non-NULL. Just deleted that error path. Fixes: 54b406e10f03 ("cdx: Remove cdx controller list from cdx bus system") Signed-off-by: Dan Carpenter Acked-by: Abhijit Gangurde --- v2: Christophe JAILLET pointed out this bug so I added this patch to the patchset. drivers/cdx/cdx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/cdx/cdx.c b/drivers/cdx/cdx.c index d84d153078d7..40035dd2e299 100644 --- a/drivers/cdx/cdx.c +++ b/drivers/cdx/cdx.c @@ -572,12 +572,11 @@ static ssize_t rescan_store(const struct bus_type *bus, /* Rescan all the devices */ for_each_compatible_node(np, NULL, compat_node_name) { - if (!np) - return -EINVAL; - pd = of_find_device_by_node(np); - if (!pd) + if (!pd) { + of_node_put(np); return -EINVAL; + } cdx = platform_get_drvdata(pd); if (cdx && cdx->controller_registered && cdx->ops->scan) From patchwork Tue Jan 2 13:11:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 184325 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4434579dyb; Tue, 2 Jan 2024 05:11:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IHHFvh/zc6VEdc3mILvv2SiW7Q63C9o2TE5R2IHEZRgd15Tj5hhQjqql3laOlMtF3fhFqwS X-Received: by 2002:ac8:5d88:0:b0:427:a048:3c4b with SMTP id d8-20020ac85d88000000b00427a0483c4bmr21917996qtx.73.1704201100784; Tue, 02 Jan 2024 05:11:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704201100; cv=none; d=google.com; s=arc-20160816; b=r9RvcHwCQVm+s1qQERjA6HwBDAPHUkZvcVGT8ar/UTotbF9fJP3DaL2AiEsD8dIw8l OtbG8z7ZvXYiZFmxYN5qqpSikA/m7zfGIQL8KhMKPzj3JJDnKuFDF5QbSgEmbUobeTP2 6n5Xe2QtHLND/aUi/ShAVJYaenQ/sQkfNmjEBIB8Mhn8LN5fr0vWHWWvRtVZm+7K04NU yLVJevhhN5idYaKvk4lGChbLaa5qZWCn8XBjpIa0adnD5NDrnG8D9ePwI0BKIX9VqxS9 VfAcS8wqh6JEFhB5yf0jbnBrJb++COj7MR70qyLuObD9EqkMRONJyg9mocBkcd2xRH+H H8Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:subject:cc:to:from :date:dkim-signature; bh=nvu173ekwBOeXVa4GusHqI3IsRPkfn6/W4VPO2scDNg=; fh=QgsB2KXrYN0XShAyGOnbg0ad15Zn1fYjo+YJLEzti6M=; b=I5cpgKutyKW1bcta4NNIIBFb7G6ZXmHSir4Qbfz+1kufFNdMtw6yJcTy/QGH8i8fbu VJ9jumF92n9mmsSXd/i0UOxGJKvv+iGks+VO5tDeDARascMjc5kObIq5nsAXDuqFJmsQ QJ7q6nmuqdOd1hRne5JnNp2dy+2Caa+UX7OewYR7boXWbKeepq7uItubIZ9F1QgY+ces eWB2dvMo5WB+K9YkuWp/ipSPlLs5mrIRReiQtH50+nVLJ/ftc5aVXfByenMRrw2AGNka Z4UNrr6JEBPEEAs/OOP2r/NaxU+x7j1V86MZnnrMUxidcL1eXXPRK0RAgBNK/mBCXPwf 7Fig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WANGHwWF; spf=pass (google.com: domain of linux-kernel+bounces-14379-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14379-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id f22-20020a05622a105600b00428340b0ae5si331353qte.731.2024.01.02.05.11.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 05:11:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14379-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WANGHwWF; spf=pass (google.com: domain of linux-kernel+bounces-14379-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14379-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 911F01C21FC3 for ; Tue, 2 Jan 2024 13:11:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 82BFAFBFE; Tue, 2 Jan 2024 13:11:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="WANGHwWF" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B19FFBFA for ; Tue, 2 Jan 2024 13:11:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-40d5aefcc2fso54390055e9.0 for ; Tue, 02 Jan 2024 05:11:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704201079; x=1704805879; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=nvu173ekwBOeXVa4GusHqI3IsRPkfn6/W4VPO2scDNg=; b=WANGHwWFz4pVgvkaUFvwTzckxUKMCHqUgFjqlKYhdmqIAp6c8lzCOkdOxlhzy+2myb ZKMAKlZcCXPd6rNkUwLxHLDJbnfJY6mhnnm/Fg3T1SUmhpP0zVhRVY6z3JR/NJ1rxjTz kjVLhtDTBRKi2E2riK2KVVUZ9GFEBSwZR+h8+DZhOw2QpXj9R48gSTta2t3K6s2pCPlJ 81BRY2ICzC+vwSKrUrh94hR9LOLTDiKWCMcRQktj0tAOpkmMA2DMhx+TXnO9X1rtnuSp bMHaiE8KoFJ1sRVuTDLB6rvKzGpTogF9145hRvtQ1DzgJehPxWGbGfGEjK2Y0wsaPFvA utyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704201079; x=1704805879; h=in-reply-to:content-disposition:mime-version:message-id:subject:cc :to:from:date:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=nvu173ekwBOeXVa4GusHqI3IsRPkfn6/W4VPO2scDNg=; b=rhJ0ZfrEmt6gm5W+l1Q9OvjBKcy01e2bwamuUV+BFFyam8+T19Z6eDFxa/y6NnM6W1 D3cowo13amQAegGC5vcJx15fQOeitZiGyDQL5ybLcroKR00+xP7tCfMFyiarSafi5/Vr eJbMpRFMFn1FH+kSVawkN85Vn0zJ+wZtjASO2okIsTuSfBDn6J0pEo1reQqp0+OFmShm qU7sNLvPRER/cFQatIpjFuRQxOYJs9Dzwc8zW/dMdbjnrCSSeD6rlR6QpWK127sr9gov E2zHeXyMypcXkvisoM5HQKXRW/DVAZzPS2sxVSgohYElOcQ+B4OMY9GCA2gHbPgYRnsW 8f3A== X-Gm-Message-State: AOJu0Yz6ox4YyuCTKgykw4BlhLuHsDMSPiyeWuN5XyixSUlGvmFWYbPu OTRr2X4awD78qBSxBdUKk6YI7SnXmA7HrA== X-Received: by 2002:a05:600c:2184:b0:40d:5c89:e254 with SMTP id e4-20020a05600c218400b0040d5c89e254mr4950796wme.71.1704201079698; Tue, 02 Jan 2024 05:11:19 -0800 (PST) Received: from localhost ([102.140.209.237]) by smtp.gmail.com with ESMTPSA id j16-20020a05600c191000b0040c11fbe581sm44799576wmq.27.2024.01.02.05.11.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 05:11:19 -0800 (PST) Date: Tue, 2 Jan 2024 16:11:16 +0300 From: Dan Carpenter To: Abhijit Gangurde Cc: Nipun Gupta , Nikhil Agarwal , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH v2 2/2] cdx: Unlock on error path in rescan_store() Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <2e66efc4-a13a-4774-8c9d-763455fe4834@moroto.mountain> X-Mailer: git-send-email haha only kidding X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786984373450229756 X-GMAIL-MSGID: 1786984373450229756 We added locking to this function but these two error paths were accidentally overlooked. Fixes: f0af81683466 ("cdx: Introduce lock to protect controller ops") Signed-off-by: Dan Carpenter Acked-by: Abhijit Gangurde --- v2: I rebased this patch on top of the other bugfix that Christophe JAILLET pointed out. It's easier for backporting to do it in this order. drivers/cdx/cdx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/cdx/cdx.c b/drivers/cdx/cdx.c index 40035dd2e299..7c1c1f82a326 100644 --- a/drivers/cdx/cdx.c +++ b/drivers/cdx/cdx.c @@ -575,7 +575,8 @@ static ssize_t rescan_store(const struct bus_type *bus, pd = of_find_device_by_node(np); if (!pd) { of_node_put(np); - return -EINVAL; + count = -EINVAL; + goto unlock; } cdx = platform_get_drvdata(pd); @@ -585,6 +586,7 @@ static ssize_t rescan_store(const struct bus_type *bus, put_device(&pd->dev); } +unlock: mutex_unlock(&cdx_controller_lock); return count;