From nobody Sun Feb 8 12:14:43 2026 Received: from mail-oa1-f49.google.com (mail-oa1-f49.google.com [209.85.160.49]) (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 6DBEA16D9AF for ; Thu, 22 Aug 2024 07:21:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724311268; cv=none; b=nG6kC9PBzAjQixzqnRZuBep3zNobKcDdJGTQIHZQHletpbI/ZpuLsh87od8G80SW5ShBaYTBoF1nbitRRnIjtFhPhK+lCth/Pq0j2PySBhXTX6PBTjyHzfC1J2lRL5q5ac+CK/dTKPQg2Jxm5J5yU1L5ajiK2UpnxHzzVaCJDN0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724311268; c=relaxed/simple; bh=NBiwkhavnp34Pc1WlCjDSkj4dCnJ5BXJFDbN6ms4Sfw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J6Geq8g5HE6PbWmjQoliuUyfrY2TXTL2iaxaQuAoaGqQo17cpKevlo/xUria8BWcSoSslo313thddXxJYvoaNaj5IEkbksCpH4s/Fl8e63kHLeFVhG5TCrw57LSwaI9VhNhy9mPJpRJja2G7T9CL/n7oDNsfSRlJizakFkfyV5g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=OnWlChbF; arc=none smtp.client-ip=209.85.160.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="OnWlChbF" Received: by mail-oa1-f49.google.com with SMTP id 586e51a60fabf-27051f63018so301638fac.3 for ; Thu, 22 Aug 2024 00:21:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1724311266; x=1724916066; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0OkXJystyHFO3QqFrhx1xRYATCv0SLvRjJj6gA62TPk=; b=OnWlChbFfXpz0H73PscU9GFIR9LDB70vb/WZDBW99U88jbckci2ScqC87Y1y6KPhJr 4lfL5wv5f6ogdghhk/v8LeAFJTAFwgF6EZ4Sd/vvNmHTlVNr3dbHnAn+QHInqLm+obiC 4t2Gd6ohpA7E87OAOVa+IyIObJHWCJtgfJCp8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724311266; x=1724916066; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0OkXJystyHFO3QqFrhx1xRYATCv0SLvRjJj6gA62TPk=; b=TRDKJUg2i+ltOYbuob5CiAauVUAwvZCwKgce3DRV/VCk+xcRlbf5+1TKMwpQWhngoO +EnMrHrMcpM/J9oFsXy1naxJvcPdsii1ru1FhCDMx0m4mL8N5MVHQfNDjlY7Qf4ebJiU mXkUNtY5ntOY5u6LZZImTPfIiwy9LNgFGPjQ6cKqpnDSHAljZe6TEU8stQ/kKhQeAbpl x1vchVewPo6j7hyF8yTScKnucvHTDbedkQVhAWprksoAWJSxOxHqhHw049MGjwihlbTv vm01vmqHSVMxtqKhsMFKTQ9n3OLPZeHB5ItvRKsZLBHeKpQJbFo9sJIKTC1eJvqn33zU SyUg== X-Forwarded-Encrypted: i=1; AJvYcCV97hRFX4QoTCiQz7EPHjBms4rLma3C527xjV8GD8yEILm9lx/eGCE04zDlUugLd2PaVRKNu0gi8/V4HiA=@vger.kernel.org X-Gm-Message-State: AOJu0YxKqfWU0R6jAlC5Can0TC8/1Op1fTgaKCLidNC2B7/4KNjzx6z8 GeVd/xcKyiFKle913vTqNpJkWRWBmDyAumL8F5OGFv0iAA68qLwNTSVC1x8VkA== X-Google-Smtp-Source: AGHT+IFzUCqhCkTr+YqoZpsRxb513kbI0DI/K30PqGR1wgWwO2DPHl2WC1ed/qu4VuxElP0+ie671w== X-Received: by 2002:a05:6871:1c6:b0:25e:7a1:ea8f with SMTP id 586e51a60fabf-273cff9bceamr1248838fac.47.1724311266536; Thu, 22 Aug 2024 00:21:06 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:8470:6a67:8877:ce2c]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7cd9ad6e8e9sm615901a12.86.2024.08.22.00.21.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 00:21:06 -0700 (PDT) From: Chen-Yu Tsai To: Mark Brown , Liam Girdwood Cc: Chen-Yu Tsai , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/3] regulator: Clarify error message for "id == NULL" in _regulator_get() Date: Thu, 22 Aug 2024 15:20:44 +0800 Message-ID: <20240822072047.3097740-2-wenst@chromium.org> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240822072047.3097740-1-wenst@chromium.org> References: <20240822072047.3097740-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The original error message simply said "get() with no identifier" without any context as to what was requested or what device the request was related to. The only thing the user or developer could do was grep for the message in the full source tree. Amend the error message to be more specific, and also use dev_* to associate the error message with a device. Signed-off-by: Chen-Yu Tsai --- drivers/regulator/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 7674b7f2df14..9029de5395ee 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2183,7 +2183,7 @@ struct regulator *_regulator_get(struct device *dev, = const char *id, } =20 if (id =3D=3D NULL) { - pr_err("get() with no identifier\n"); + dev_err(dev, "regulator request with no identifier\n"); return ERR_PTR(-EINVAL); } =20 --=20 2.46.0.184.g6999bdac58-goog From nobody Sun Feb 8 12:14:43 2026 Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) (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 C6B40183061 for ; Thu, 22 Aug 2024 07:21:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724311270; cv=none; b=pxhUHlYVaZQZbXANuI5x5hUCaqRCaxZxxp0FdJ5QkW2yqRFZaKgCRDD4675wWpzOt3mRxrvcChvcYlcJMVzRJwk0BUhshBzUXmDF+rE0x8EmJmKVfxcWBpySx2/5Idj1D6Ao2pO4/P5QGNxh539gPG4Qc8iYTUAX0HHZSVDxKu8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724311270; c=relaxed/simple; bh=HIEBQW++vDG5a745kTyn+OTlys7QVPwisgFVgoxNyoY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CFyiuMl7HVYCY2BYaYDpRz/EQr/r4F2LX7BuNK6oc2Zvq73qGBh+FiHm5beAf9fgpg44PL+q3y+GOgaGOYqA0htgf9pepQh9txeO5J00FWrf2BLHlkdM6romNxE7s+zkX2Re85guX6nYT2lLN0r7aKnFKQ4AOewns/JR3wsHgzI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=I6Osmka2; arc=none smtp.client-ip=209.85.215.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="I6Osmka2" Received: by mail-pg1-f175.google.com with SMTP id 41be03b00d2f7-7cd76b56e59so171706a12.2 for ; Thu, 22 Aug 2024 00:21:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1724311268; x=1724916068; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3scZTUqJnjgMpybUwcFhKq0rNyJDiP6vw8cgGHLTR6o=; b=I6Osmka2tQZjmQhHUlUljwklRpsynQR5QkuuF5s+oKA7SK4k0WWNHXKlT836ElgMf+ zuliiADjygIO97hw1O6wBD0uxlQMJlrbJP8McZPevVSoYH8M8GL3RoGMOAbFNjjSoojg LFr1UPlyWdrPmbUrMuBZTq7Y2Whb0s6XS9JHA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724311268; x=1724916068; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3scZTUqJnjgMpybUwcFhKq0rNyJDiP6vw8cgGHLTR6o=; b=NQgz7HsjNYmLtjzndODhnVZyHhZzyk7+Ry/G+h6YkX+2+Y+c/UQ6hTpkiuB7BA84pr fXIcuOzWgsNCkwY2ffQZieWpxIIrxlaURfMNZu3p8plYJBQ4yPk+V6CDjr7InAfOGk3f DN81OEp6yM3/s4jhF8GWjNfPXbNwLg2M07jMNRHdbksiHp3WujjAK7dGjuyjLj8X1lzU Xf6RdbVtdR5S7YTJPAszFG8HDQR1bPg9Gva2bWrNPXC9+7JMFeERpt9527TKpnCMWSNy dcgSGHoDZSlPG1itIbSxmH2s3Bpfn7RO5QsNTP/wlWasR0fV/1QjkIYidUuZMemsMspe y7yg== X-Forwarded-Encrypted: i=1; AJvYcCWcZsPCQqGUMUBkHGXcxKJ6EZDKHhKKp2MpiOPklfJEcORevTEnxa5urCkEI5Ol9XlzHwjfUV/B8dGue4k=@vger.kernel.org X-Gm-Message-State: AOJu0YxHo6H7O1PLYWfzbB7s2sDIDQpn2lPJ/A/fnLe5vOWfAD8iFOp2 rlacltE+z58UZEp7zH6OwEQyQt/W/LfAR9Fvr21vpruWdtMUIG6gsRxNtMfShEGgh/HbFBoGWIU = X-Google-Smtp-Source: AGHT+IGZC3R+I2VvA89HYxYSg4Ao+WE/aEJPwMMpjyENZGIwsc8WIExLuTmv5nBr89XIrOEWeKGuAg== X-Received: by 2002:a05:6a20:6f08:b0:1c1:a25c:745e with SMTP id adf61e73a8af0-1cad7f896admr5742758637.17.1724311268106; Thu, 22 Aug 2024 00:21:08 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:8470:6a67:8877:ce2c]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7cd9ad6e8e9sm615901a12.86.2024.08.22.00.21.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 00:21:07 -0700 (PDT) From: Chen-Yu Tsai To: Mark Brown , Liam Girdwood Cc: Chen-Yu Tsai , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/3] regulator: Return actual error in of_regulator_bulk_get_all() Date: Thu, 22 Aug 2024 15:20:45 +0800 Message-ID: <20240822072047.3097740-3-wenst@chromium.org> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240822072047.3097740-1-wenst@chromium.org> References: <20240822072047.3097740-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If regulator_get() in of_regulator_bulk_get_all() returns an error, that error gets overridden and -EINVAL is always passed out. This masks probe deferral requests and likely won't work properly in all cases. Fix this by letting of_regulator_bulk_get_all() return the original error code. Fixes: 27b9ecc7a9ba ("regulator: Add of_regulator_bulk_get_all") Signed-off-by: Chen-Yu Tsai --- drivers/regulator/of_regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regula= tor.c index 03afc160fc72..86b680adbf01 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -777,7 +777,7 @@ int of_regulator_bulk_get_all(struct device *dev, struc= t device_node *np, name[i] =3D '\0'; tmp =3D regulator_get(dev, name); if (IS_ERR(tmp)) { - ret =3D -EINVAL; + ret =3D PTR_ERR(tmp); goto error; } (*consumers)[n].consumer =3D tmp; --=20 2.46.0.184.g6999bdac58-goog From nobody Sun Feb 8 12:14:43 2026 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (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 82EF6183CB5 for ; Thu, 22 Aug 2024 07:21:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724311272; cv=none; b=fdePprTF7VwFfnTwySLq/cRoh3H4CeYqo5XvfI5AcwxXW2ruqCMx7pCpQWFcVCkcRbTed2t84atAIqx9/c7uvak26Kce3lKSfbCnLz36qAtSODFRKEnBHqHfexa+pEQPRKyeUg+cb3zgXJf5dTBKsQOCRA/gJY8GM40na5w9V3Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724311272; c=relaxed/simple; bh=IV4SyJehbykvQ8y0yyNptHimzKJq/3QQZb7fgel7Lg8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hTnDQe2YTw7YXPDvdUnFCt5Y3/WsYZRd0TrWZsgc6TmJz+ZqWFotWBNc21cB+Uss0XVRZvxH+EZsjUF9hRjvhYyVMxxqoSe2CdxIMmBK76TxEIqO6lcC3TS1iSfosKJ99VjeOY+rJPBp7R5xgl44YDaQjLODrENqXZesUxwGSU8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=iTQtEtUr; arc=none smtp.client-ip=209.85.210.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="iTQtEtUr" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-7143185edf2so430466b3a.0 for ; Thu, 22 Aug 2024 00:21:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1724311270; x=1724916070; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VmtdE26bYTfUEgEWFh+anX0TX6bAFO2PB6s9GZztsew=; b=iTQtEtUr6gmbHpNh8ewVP21RzwhhFcIP85QdpKyQ2+ZYYW8bSzcYttGrL/x0gJnr6n RdUvNbffFiC1bMXDHesMgsXP8T4t7lELsZv1jtNig18JUhO1nOhNN92Fz45C2tQyrYJC ziHgHyI+y9iqUtqD5LaeWUESlWy+0kePaSfK0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724311270; x=1724916070; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VmtdE26bYTfUEgEWFh+anX0TX6bAFO2PB6s9GZztsew=; b=JBYamNZuUFrg0IRKBIpY3iy8Eodjwji4FufX9KMTFRfIfHbqPdvvr2NNirAe63nQJS ef7ERA65rpS4APBkV+DyQY9DeROEOqxbYBPunOpLu32iLUoDn5V/qrzOfUlyZnx3K62+ 0t5sNVOa186Y1n1NaXdy/oYmfFUXf6gYXBZO8cSoQACGGvn/S14SrtKM/CcJ89Sjg6sz xyTnJIeGnfcxRmXkOPTj5rUmfdKZq67Xowb3mUOZ0u3HeK9qZd57Pd7pVgbfjr0OB6ON f5vgJihEwv6OOlCpOKEbvy5YBR/lvr22vZQh8l3yVonNoppvRjNCCnD6crDyrK3h4vQK aNlw== X-Forwarded-Encrypted: i=1; AJvYcCXvu141KVeDatrKmczr7pIIJE7wPcIPDCyL8MZsIzsABWuUoiPaogEOJlF2qCELFSsSOs4Nh5daCuK1kNw=@vger.kernel.org X-Gm-Message-State: AOJu0Yx0Sz06RkOLHCgSqBaP4RssxxbzwEI0hal5UbYKbi4t9CGDYYGC rel/Fkx/UnxGiUVAROPTiGAQzjq/04gpZbEN8wI/0Lfi+e1V9XPNI2UzsPkrZQ== X-Google-Smtp-Source: AGHT+IGMB+dxjMGNVTHtpKof2PSsuFIg3K1prvJcIxcnrkvlZkXjsgC23fdUHqucez9Q1lukNxGFiA== X-Received: by 2002:a05:6a00:10c4:b0:706:29e6:2ed2 with SMTP id d2e1a72fcca58-71436488fd8mr1064777b3a.5.1724311269746; Thu, 22 Aug 2024 00:21:09 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:8470:6a67:8877:ce2c]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7cd9ad6e8e9sm615901a12.86.2024.08.22.00.21.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 00:21:09 -0700 (PDT) From: Chen-Yu Tsai To: Mark Brown , Liam Girdwood Cc: Chen-Yu Tsai , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/3] regulator: Fully clean up on error in of_regulator_bulk_get_all() Date: Thu, 22 Aug 2024 15:20:46 +0800 Message-ID: <20240822072047.3097740-4-wenst@chromium.org> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240822072047.3097740-1-wenst@chromium.org> References: <20240822072047.3097740-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently in of_regulator_bulk_get_all(), if any regulator request fails, the error path releases all regulators already requested, but leaves the |struct regulator_bulk_data| memory to the caller to free, and also leaves the regulator consumer pointers dangling. The latter behavior is not documented, and may not be what the caller is expecting. Instead, explicitly clean up everything on error, and make it clear that the result pointer is only update if the whole request succeeds. Signed-off-by: Chen-Yu Tsai --- drivers/regulator/of_regulator.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regula= tor.c index 86b680adbf01..d557f7b1ec7c 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -747,19 +747,19 @@ static int is_supply_name(const char *name) * This helper function allows drivers to get several regulator * consumers in one operation. If any of the regulators cannot be * acquired then any regulators that were allocated will be freed - * before returning to the caller. + * before returning to the caller, and @consumers will not be + * changed. */ int of_regulator_bulk_get_all(struct device *dev, struct device_node *np, struct regulator_bulk_data **consumers) { int num_consumers =3D 0; struct regulator *tmp; + struct regulator_bulk_data *_consumers =3D NULL; struct property *prop; int i, n =3D 0, ret; char name[64]; =20 - *consumers =3D NULL; - /* * first pass: get numbers of xxx-supply * second pass: fill consumers @@ -769,7 +769,7 @@ int of_regulator_bulk_get_all(struct device *dev, struc= t device_node *np, i =3D is_supply_name(prop->name); if (i =3D=3D 0) continue; - if (!*consumers) { + if (!_consumers) { num_consumers++; continue; } else { @@ -780,25 +780,28 @@ int of_regulator_bulk_get_all(struct device *dev, str= uct device_node *np, ret =3D PTR_ERR(tmp); goto error; } - (*consumers)[n].consumer =3D tmp; + _consumers[n].consumer =3D tmp; n++; continue; } } - if (*consumers) + if (_consumers) { + *consumers =3D _consumers; return num_consumers; + } if (num_consumers =3D=3D 0) return 0; - *consumers =3D kmalloc_array(num_consumers, + _consumers =3D kmalloc_array(num_consumers, sizeof(struct regulator_bulk_data), GFP_KERNEL); - if (!*consumers) + if (!_consumers) return -ENOMEM; goto restart; =20 error: while (--n >=3D 0) - regulator_put(consumers[n]->consumer); + regulator_put(_consumers[n].consumer); + kfree(_consumers); return ret; } EXPORT_SYMBOL_GPL(of_regulator_bulk_get_all); --=20 2.46.0.184.g6999bdac58-goog