Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp183758lqb; Thu, 14 Mar 2024 08:32:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVMJa2dabzfd8uDab7nhQ1tqBZg91zVZ9f9FX4TZinvQJA2fhglJZxGiiyCPI+NlGj2+cGDM6oZS3iP0RTu0IMwBWo5MOECJOvhvrjIGQ== X-Google-Smtp-Source: AGHT+IGDl39dJIf4orWSg48uyKyRvtP8nLOm5dpzWqKaczA8WfBdVPmweqq2JCBG/lNrXJWRjWTi X-Received: by 2002:ac8:7f8e:0:b0:430:9740:ef2a with SMTP id z14-20020ac87f8e000000b004309740ef2amr2135105qtj.6.1710430324976; Thu, 14 Mar 2024 08:32:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710430324; cv=pass; d=google.com; s=arc-20160816; b=CGnhGIAUISwoTetR8v65xaU7VrkBECbDXwqZm1x7CMsW2xv4waCi0AU7CDwi9F3fh4 K1vnB2VYjclOKfqoXb+uwibIacA0pZExroNJgeNCYdGoC2GGAFKYGvpap/oMS99joUh8 c5dZiTypgyGmEuU2v50ZonPGu7wc0hrEky4pHQtq4n4sBo82HszUHs2cWGrc9ZWIyqYv 6oRVoFhhXR/JBQqa7IJRkcUlZnpKfe/FcxRkYei0bRuIpTT/QPAAd+dBvVTsYNRNlqyX 7e0fhbJAueQ8PQJVuHReE4WbgK+AF3ZXUPPwbv9MN5EH4VJkt4tqmQ2AA7i2cVUUKbub D19w== ARC-Message-Signature: i=2; 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:references:message-id:subject:cc :to:from:date:dkim-signature; bh=1GzIPdAccPQ9M4f+gmSEp7mIKo4xnW7trDdRbAnf9uA=; fh=YoAMxMurytoz58CvHQNw4k0dznWo4OGSvaL9HXRKH0M=; b=eUqjPDrk1lBG+NbETip/jFMvTg976UOH4OdwyCKf5EAPkA4AmYRcyVlhQEhHFIcua+ E7MVvUwST2VjIB5cBwVKFylA4oeRUBllxBZ8q0aaenlPvqSuPoPALvo9cdIrPzZsh076 9+5hbIWdD1EDnpTW0fZm/iIlD4ttBW9SqxZtU54RbXG5PWn1PUeU+6AvALABcE1hWlnE VxxYzEDuEbTikr1lJ7CQfjeDhBr/jZ6icF73TPoeQd/w0srXNoen5DzZKVskUXFv9gkr sITVRTKQ/jzQDH8+sQdVordrwNNCUsqsAhbm53cx0LUoZN1UstDD+8BJpEjR2rnxH5at 218Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xd5TpQcb; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-103496-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103496-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d21-20020ac85ad5000000b0042ef58238f7si1682855qtd.34.2024.03.14.08.32.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 08:32:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-103496-linux.lists.archive=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=xd5TpQcb; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-103496-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103496-linux.lists.archive=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 A16561C20AA3 for ; Thu, 14 Mar 2024 15:32:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6891271B5E; Thu, 14 Mar 2024 15:31:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="xd5TpQcb" Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (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 A952171B34 for ; Thu, 14 Mar 2024 15:31:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710430303; cv=none; b=KPXfWpWZDZDDoVdyc1H+S+5U7QiOLLtnx6fIiiLZZYWG4MQuCQWXqvx5GDL0hdcyDcc66qMntsSfHXgFidiClwlD5L7gAhs1v4YOWCF6tuQe+GKKVgj6f9D7GxGPC4RR2qHWEkUJYkXWoWng7a54FFvWmkZIrutGTL4YntAA92c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710430303; c=relaxed/simple; bh=a04JHFqxyI3Ydds0JExQwGiYuxf/v3UlCkqU51U9XzY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rvLUXgzka2yblzGPkzcFrSQG15RtsTcYlB8NVabFMm39zJ5zVoZrL0/Tp+REoU75VUKmtYY8ceh4jYEkBE0sG5BUJZNoFsgukVSbwZLR29LjyPF1ON9TwD7Mn4TNGcdwa2OXR2t2sP+LztdOJUu4S5nfM4efTc92ZDsTlY45exQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=xd5TpQcb; arc=none smtp.client-ip=209.85.167.46 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-lf1-f46.google.com with SMTP id 2adb3069b0e04-512b3b04995so1149166e87.3 for ; Thu, 14 Mar 2024 08:31:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710430300; x=1711035100; darn=vger.kernel.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=1GzIPdAccPQ9M4f+gmSEp7mIKo4xnW7trDdRbAnf9uA=; b=xd5TpQcbv1kNo4CktlTHRl9cfeTpEjRqWIWROfxWyG6GNOb+VUrgfbGJ+DfEGKb4OG /yMtMwJB+fXAFaT59MqxEq49uYfYDBrQFpk57LBKYBy9f9ySh/tQkqlkuiC1vpmr5uJR GxQEhLQYFNT2GvZN9su2pN6UCrx9eSinbythoy60omw0CfglmaCWWUH+R9f9JrBepXUQ /CNxGOev+TeEIDvbyO+jr0A+mjcf8YJeni9MAL7nk1XXvqcv4uZ+Ea7w34OiD8mKCOER P/jq/oRwIXYl73IqQ3Mjyd38HbsNEujYLbDpk0tWfsOWME6QU5RALDDS193ZUj02nE98 jHig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710430300; x=1711035100; 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=1GzIPdAccPQ9M4f+gmSEp7mIKo4xnW7trDdRbAnf9uA=; b=cHgeT45QYfhOk8i6+NbGAox5+9/5roPnmFDxWvoC3XI4PxnnEtYEmCbwBjJ1sBcvtv aLZzvjmrL1Z1o8aImKiDOo23+hpisHxsRBmRuqZgF08uGneZ2qWxnifJIeqV9C05346T hR021yevLEYu5AZlESeWHvYl5+tk+AQp1hbGwsADjGo1d9PeQPo768d8iRCYjKP84yyR d98+gWNkOsxw3AWaO++T4WYp/GMoHQq//31XDp84ycRqYehpOIonnuzIfInQDWeG6CiY OP71PSEZ9owV0nUybyz3YeVhI4E802EV/pwtPJe2qcSIvvvLbhxMnLmcuw04TwHxf2gN 8vUw== X-Forwarded-Encrypted: i=1; AJvYcCXA86I1oQV55R4AVdc/qYVMCZYKjWc3rtvJMEwwIwxkOgvO5Ok49uVq1z+5aCLEdTGaTaXq4fmyfNTFNmpQQIO6BJeNVsycX+AxyEIk X-Gm-Message-State: AOJu0Yx01SRKdOLavQus0FJuqUTtAcbkyRw89WQEMosTVEdasjvrfSCd yOrLkeu65Ivd05rI3HqxQT57U2KB/ZlQdMnMWBr8NOSSg2Sj6UIbQY0F6gpHeCs= X-Received: by 2002:a19:ad02:0:b0:513:5a09:abbe with SMTP id t2-20020a19ad02000000b005135a09abbemr343146lfc.67.1710430299586; Thu, 14 Mar 2024 08:31:39 -0700 (PDT) Received: from localhost ([102.222.70.76]) by smtp.gmail.com with ESMTPSA id l5-20020a05600c1d0500b00412ea52b102sm6053706wms.34.2024.03.14.08.31.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 08:31:39 -0700 (PDT) Date: Thu, 14 Mar 2024 18:31:35 +0300 From: Dan Carpenter To: "Peng Fan (OSS)" Cc: Sudeep Holla , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Oleksii Moisieiev , Linus Walleij , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, AKASHI Takahiro , Peng Fan Subject: Re: [PATCH v5 4/4] pinctrl: Implementation of the generic scmi-pinctrl driver Message-ID: <55ec2392-c196-4669-a339-12ef336707fa@moroto.mountain> References: <20240314-pinctrl-scmi-v5-0-b19576e557f2@nxp.com> <20240314-pinctrl-scmi-v5-4-b19576e557f2@nxp.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240314-pinctrl-scmi-v5-4-b19576e557f2@nxp.com> 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. regards, dan carpenter > + if (ret) { > + dev_err(pmx->dev, "Unable to get function groups, err %d", ret); > + return ret; > + } > + > + *num_groups = pmx->functions[selector].num_groups; > + if (!*num_groups) > + return -EINVAL; > + > + pmx->functions[selector].groups = > + devm_kcalloc(pmx->dev, *num_groups, > + sizeof(*pmx->functions[selector].groups), > + GFP_KERNEL); > + if (!pmx->functions[selector].groups) > + return -ENOMEM; > + > + for (i = 0; i < *num_groups; i++) { > + pmx->functions[selector].groups[i] = > + pinctrl_scmi_get_group_name(pmx->pctldev, > + group_ids[i]); > + if (!pmx->functions[selector].groups[i]) { > + ret = -ENOMEM; > + goto err_free; > + } > + } > + > + *groups = (const char * const *)pmx->functions[selector].groups; > + > + return 0; > + > +err_free: > + devm_kfree(pmx->dev, pmx->functions[selector].groups); > + > + return ret; > +}