Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 00d8d627 authored by Sarang Joshi's avatar Sarang Joshi
Browse files

coresight: check if gpio count is positive before using



If gpio entries are not present in dt file, the resource query
function returns negative value for gpio count. Currently data
type for gpio count is unsigned int which wraps around and gives
positive result for negative value that causes failure while
probing the driver. Modify gpio count data type to integer and
check if it is positive before using it.

Change-Id: I1596f3d1090f5caa70735c66e10f82914ac7ab26
Signed-off-by: default avatarSarang Joshi <spjoshi@codeaurora.org>
parent c936945a
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -96,11 +96,11 @@ struct tpiu_drvdata {
	unsigned int            reg_lpm_io;
	unsigned int            reg_hpm_io;
	enum tpiu_set		set;
	unsigned int		seta_gpiocnt;
	unsigned int		*seta_gpios;
	int			seta_gpiocnt;
	int			*seta_gpios;
	struct gpiomux_setting	*seta_cfgs;
	unsigned int		setb_gpiocnt;
	unsigned int		*setb_gpios;
	int			setb_gpiocnt;
	int			*setb_gpios;
	struct gpiomux_setting	*setb_cfgs;
	bool			enable;
	bool			nidnt;
@@ -805,7 +805,7 @@ static int tpiu_parse_of_data(struct platform_device *pdev,
	drvdata->set = TPIU_SET_B;

	drvdata->seta_gpiocnt = of_gpio_named_count(node, "qcom,seta-gpios");
	if (drvdata->seta_gpiocnt) {
	if (drvdata->seta_gpiocnt > 0) {
		drvdata->seta_gpios = devm_kzalloc(dev,
				sizeof(*drvdata->seta_gpios) *
				drvdata->seta_gpiocnt, GFP_KERNEL);
@@ -873,7 +873,7 @@ static int tpiu_parse_of_data(struct platform_device *pdev,
	}

	drvdata->setb_gpiocnt = of_gpio_named_count(node, "qcom,setb-gpios");
	if (drvdata->setb_gpiocnt) {
	if (drvdata->setb_gpiocnt > 0) {
		drvdata->setb_gpios = devm_kzalloc(dev,
				sizeof(*drvdata->setb_gpios) *
				drvdata->setb_gpiocnt, GFP_KERNEL);