Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6438505ybi; Wed, 31 Jul 2019 14:30:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqxlwhNrL5b1sXMjFx6YHwIupHbV8+E8TCGpnnjqBFKrkXH4TcRUm8oisvJYxRDWXIki4q1Z X-Received: by 2002:a17:902:24c:: with SMTP id 70mr121453571plc.2.1564608650423; Wed, 31 Jul 2019 14:30:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564608650; cv=none; d=google.com; s=arc-20160816; b=zKJVvxEF+MMn7tk5PjuBhIFNhge/SnY7IDKrGZm8b19eRkd0IhYNcqn/5B7KWpWdwx 1dn9Dq5kNNmiPBlC0aWliBE2DfGc5SPiuV1RJnt1Gf0ZBOW60anwpVZiB7GBqKCm+hyF uDnz3wvYUFmLCtfNJBBWF5XQ7CAcEv5cJEFiyLlt0R7LQNAmEW1oRM3u45UlNKGCUBSX mZ1h/XT7YI5uMWpUntZe2UJZ4snTG336ybCqT8BAb7klCgD6IPFfgIek8IqExxQkCNzt R1LP3VtSA+lMA5NFfzazFZG7Kr01JXzkIwdTM0F9o0Pv2i1lzxYvtYzqH6sw4eQsZ36B brgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=EmXYNSCzBw0xpbjuYL273WSZ1hCgZdid2rVUUu0J0oY=; b=iGP0qvLhlH83VwMsboWjNrspEW0dEWk6y33Vrev9UrsjkNV3ik8DgbyR5EPFeUWTUq Fvses+TbDG577tEr7nqpBF+aF+/ZcPMpVdcojy6DtnRwewI/Uq2xxOoMLRsBhx9NeuCr fK2oDksqvPB59l0rvSjO2j4rAkLDAcJgFnyC5U4ExXlL8nbpSfDZBHchyYnY1B6rOw83 wBlLFV5CsFxeQTWCEvdcNh4v1GF5ozmKmvYkTuODYnRuADVwc1xWbRquQ3nXP4gESwuv w3qib3tpZYKXiDamfrUzDCc2b4VjnvcUWpneZCVIZ6DIZScExfo90l+v53PaeNih/iji sHTg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p3si2258408pjr.18.2019.07.31.14.30.35; Wed, 31 Jul 2019 14:30:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729439AbfGaSTb (ORCPT + 99 others); Wed, 31 Jul 2019 14:19:31 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:46280 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729178AbfGaST0 (ORCPT ); Wed, 31 Jul 2019 14:19:26 -0400 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id 520CD80292; Wed, 31 Jul 2019 20:19:12 +0200 (CEST) Date: Wed, 31 Jul 2019 20:19:23 +0200 From: Pavel Machek To: pavel@ucw.cz Cc: linux-kernel@vger.kernel.org, Stefan Roese , Mika Westerberg , Andy Shevchenko , Yegor Yefremov , Giulio Benetti , Sasha Levin Subject: Re: [PATCH 4.19 038/113] serial: mctrl_gpio: Check if GPIO property exisits before requesting it Message-ID: <20190731181923.GB821@amd> References: <20190729190655.455345569@linuxfoundation.org> <20190729190704.872773204@linuxfoundation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="kORqDWCi7qDJ0mEj" Content-Disposition: inline In-Reply-To: <20190729190704.872773204@linuxfoundation.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --kORqDWCi7qDJ0mEj Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > This patch implements the fix suggested by Mika in his statement above. > @@ -12,6 +12,7 @@ > #include > #include > #include > +#include > =20 > #include "serial_mctrl_gpio.h" > =20 > @@ -115,6 +116,19 @@ struct mctrl_gpios *mctrl_gpio_init_noauto(struct de= vice *dev, unsigned int idx) > =20 > for (i =3D 0; i < UART_GPIO_MAX; i++) { > enum gpiod_flags flags; > + char *gpio_str; > + bool present; > + > + /* Check if GPIO property exists and continue if not */ > + gpio_str =3D kasprintf(GFP_KERNEL, "%s-gpios", > + mctrl_gpios_desc[i].name); > + if (!gpio_str) > + continue; So if this fails, we'll let the system boot in different configuration than usual. I guess GFP_KERNEL allocation failures are really rare, but would it be worth a message? Or maybe buffer on the stack so we don't do allocations in a loop, and so that allocation can't fail? Thanks, Pavel > + present =3D device_property_present(dev, gpio_str); > + kfree(gpio_str); > + if (!present) > + continue; > =20 > if (mctrl_gpios_desc[i].dir_out) > flags =3D GPIOD_OUT_LOW; --=20 DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany --kORqDWCi7qDJ0mEj Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAl1B26sACgkQMOfwapXb+vLWFgCcCNHawpwrqsLf+elAJ+kA2obE /5gAn0iAV/T/H4ZF/gX+eIC1/2NLLYiE =nyr/ -----END PGP SIGNATURE----- --kORqDWCi7qDJ0mEj--