From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4D68CC54E66 for ; Fri, 15 Mar 2024 06:24:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Zlmh4YD2xHFkW6arcGhYxM/5JnfAEUbm1Xhu0lef7eM=; b=YbPvbgEuszb3OG VeLLbbrc/8UM3kJ0ayNaDtAmURh4PkHana2xbyKsL8n/Qzl+0e50aYN9a2K+S+484M4IkjYE1zajw qIE/5X1k+e1hDpcCkHdPh8yc36CCYkbz8lVEPIOKuVdz7LBkoxyfj907nn39SVlAuHxNLwJi3tXqC tS5O5RGxgljCsdWxJ9NEfznMbkMNOdyEBKnNpcyficFQq561K3zygcZn+VZ6C3TvyurzfRLLx+Nzf vyliqMy6QD2aDLIpKUe21Txr7DcoxQ52usQECCgZTIRlN6ddy+tWCD5hoqDlhEssXmU6J2EmIe8Rr ukLw967haK0+afZhDxcQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rl0zG-0000000GpJq-1X5p; Fri, 15 Mar 2024 06:24:14 +0000 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rl0zC-0000000GpIc-2IGU for linux-arm-kernel@lists.infradead.org; Fri, 15 Mar 2024 06:24:12 +0000 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-33e5978fc1bso863792f8f.3 for ; Thu, 14 Mar 2024 23:24:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710483847; x=1711088647; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=s9LPhepAIkivg02JjKy3gGkvg0KX9KjTZMR9ul/pzXw=; b=EDwHh9NWRQgIZMPrP/8odg5hJQS2xTg/V1t9y/vsLo4IEcEdfnnuspbzhDAEVsNmOQ ZWtOrdeX2t8VldYkr59MJw2UUTflk8/y+vCElMaHDJONbSU3ZBZgTKOZz3BXDd3+U7wY Gv+FsMFhHe1N08pjfPEMnemCy69apUJKCF73vqXasN2fID3O04nulVRE75/VPoS1IUQc ztApe8he0WIYSJZLm+HOphD4a+8OTSIk97o7zVgnXCYlLIMauFSuQ1Bv+wsv2941nxyC kv8hQb+ALmMIJWYZ5Nw8ZgWoX89htjuDYA1p3mEB8oq4blviClya6CcWNIHEQFa7z3f5 WBlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710483847; x=1711088647; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=s9LPhepAIkivg02JjKy3gGkvg0KX9KjTZMR9ul/pzXw=; b=JO/DwbiKhEi4wNfpTTuCehW+xZnU6GG2gms43kthyGf30Da4Xjn5zxmiao0ctwvHyh PZRWwNRxLuRkwqVkykGkm0sJNCIOyEkjSUvnz/mTqapLnEBFTPvePKrJyGU8s3xwyVyM mQHlnOBH/GOw1uRq/ipRKJAVHZrH5NvtxhpnES4VGnV9mm4E+nMgdH5HVusOu6R1Y83t DMa4RJjZPEZaHMimNdqXp9whQmz+xSjyuDByqR9Y8y1bUhj0rj/1hqw48ykG+EDsgUvr NsS7YRt8HUPyNMrNhLsKRPO1mntNmfwtIcs710mgruphy9gqYk+Yp/Rw9yBT5MLAm4u/ qaAQ== X-Forwarded-Encrypted: i=1; AJvYcCWWmi1f9WRRSd3mu+yTUBKvODZ9n2UxzEb0fO3/qVLoevZMHjMVN+PA+mZkHgqJhKTL281mbZyM8Stt8r62i7bx+IfUNpK66fqEfDGMpz9xtkYaCAA= X-Gm-Message-State: AOJu0YxrXZoPk8LRQaq6fWHWM+8EWkgppigmAyHgiqGNkdCjdKQP/oYV gkLFvr8dTUwzkbdHL0LUjd050cAhQ6nhXGYGcqjrC48ptpRzunHXUL3NV/FZ+zQ= X-Google-Smtp-Source: AGHT+IGuc1jijyMO18jNQFeSjG/gNhcDM/wtNd54nQwkBqzISLhJ08o59pWhpo7tuOIhvoHzQzAu1g== X-Received: by 2002:a05:6000:a90:b0:33e:4238:8615 with SMTP id dh16-20020a0560000a9000b0033e42388615mr2698769wrb.40.1710483847319; Thu, 14 Mar 2024 23:24:07 -0700 (PDT) Received: from localhost ([102.222.70.76]) by smtp.gmail.com with ESMTPSA id dd12-20020a0560001e8c00b0033eab3520a9sm2384912wrb.43.2024.03.14.23.24.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 23:24:06 -0700 (PDT) Date: Fri, 15 Mar 2024 09:24:02 +0300 From: Dan Carpenter To: Peng Fan Cc: "Peng Fan (OSS)" , Sudeep Holla , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Oleksii Moisieiev , Linus Walleij , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , dl-linux-imx , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-gpio@vger.kernel.org" Subject: Re: [PATCH v5 4/4] pinctrl: Implementation of the generic scmi-pinctrl driver Message-ID: <64523bd3-d208-4989-b8d9-57952c77954c@moroto.mountain> References: <20240314-pinctrl-scmi-v5-0-b19576e557f2@nxp.com> <20240314-pinctrl-scmi-v5-4-b19576e557f2@nxp.com> <55ec2392-c196-4669-a339-12ef336707fa@moroto.mountain> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240314_232410_659693_47C7581D X-CRM114-Status: GOOD ( 19.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Mar 15, 2024 at 12:44:34AM +0000, Peng Fan wrote: > > Subject: Re: [PATCH v5 4/4] pinctrl: Implementation of the generic scmi- > > pinctrl driver > > > > On Thu, Mar 14, 2024 at 09:35:21PM +0800, Peng Fan (OSS) wrote: > > > +static int pinctrl_scmi_get_function_groups(struct pinctrl_dev *pctldev, > > > + unsigned int selector, > > > + const char * const **groups, > > > + unsigned int * const num_groups) > > { > > > + const unsigned int *group_ids; > > > + int ret, i; > > > + struct scmi_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev); > > > + > > > + if (!groups || !num_groups) > > > + return -EINVAL; > > > + > > > + if (selector < pmx->nr_functions && > > > + pmx->functions[selector].num_groups) { > > > > If pmx->functions[selector].num_groups is set then we assume that > > functions[selector].groups has been allocated. > > > > > + *groups = (const char * const *)pmx- > > >functions[selector].groups; > > > + *num_groups = pmx->functions[selector].num_groups; > > > + return 0; > > > + } > > > + > > > + ret = pinctrl_ops->function_groups_get(pmx->ph, selector, > > > + &pmx- > > >functions[selector].num_groups, > > > + &group_ids); > > > > However, pmx->functions[selector].num_groups is set here and not cleared > > on the error paths. Or instead of clearing the .num_groups it would be nice > > to pass a local variable and only do the > > pmx->functions[selector].num_groups = local assignment right before the > > success return. > > So you concern is I should clear the pmx->functions[selector].num_groups in > err path, right? > Yes. If functions[selector].groups is invalid (NULL or freed) then the pmx->functions[selector].num_groups variable must also be zero. regards, dan carpenter _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel