mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Riyan Dhiman <riyandhiman14@gmail.com>
Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
	linux-staging@lists.linux.dev
Subject: Re: [PATCH] staging: vme_user: added bound check to geoid
Date: Tue, 27 Aug 2024 11:40:59 +0300	[thread overview]
Message-ID: <8d62104c-ac1f-447a-8b53-cad4e66a6c8d@stanley.mountain> (raw)
In-Reply-To: <20240827055555.65371-1-riyandhiman14@gmail.com>

On Tue, Aug 27, 2024 at 11:25:55AM +0530, Riyan Dhiman wrote:
> diff --git a/drivers/staging/vme_user/vme_fake.c b/drivers/staging/vme_user/vme_fake.c
> index 7f84d1c86f29..d93a5d428ab9 100644
> --- a/drivers/staging/vme_user/vme_fake.c
> +++ b/drivers/staging/vme_user/vme_fake.c
> @@ -1059,6 +1059,13 @@ static int __init fake_init(void)
>  	struct vme_slave_resource *slave_image;
>  	struct vme_lm_resource *lm;
>  
> +	/* If geoid provided, validate it is positive and less than VME_MAX_SLOTS */
> +	if ((geoid) && (geoid < 0 || geoid >= VME_MAX_SLOTS)) {
            ^^^^^^^
Too many parentheses, but really there is no need for this.  Just write:

	if (geoid < 0 || geoid >= VME_MAX_SLOTS) {

> +		pr_err("VME geographical address must be between 0 and %d (exclusive), but got %d\n",
> +			VME_MAX_SLOTS, geoid);
> +		return -EINVAL;
> +	}
> +
>  	/* We need a fake parent device */
>  	vme_root = root_device_register("vme");
>  	if (IS_ERR(vme_root))
> diff --git a/drivers/staging/vme_user/vme_tsi148.c b/drivers/staging/vme_user/vme_tsi148.c
> index d81be8e4ceba..97323b5563e8 100644
> --- a/drivers/staging/vme_user/vme_tsi148.c
> +++ b/drivers/staging/vme_user/vme_tsi148.c
> @@ -2252,6 +2252,13 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>  	struct vme_dma_resource *dma_ctrlr;
>  	struct vme_lm_resource *lm;
>  
> +	/* If geoid provided, validate it is positive and less than VME_MAX_SLOTS */
> +	if ((geoid) && (geoid < 0 || geoid >= VME_MAX_SLOTS)) {
> +		pr_err("VME geographical address must be between 0 and %d (exclusive), but got %d\n",
> +			VME_MAX_SLOTS, geoid);

Here you have a device pointer so can use dev_err(&pdev->dev, ... instead of
pr_err().

regards,
dan carpenter

> +		return -EINVAL;
> +	}


  reply	other threads:[~2024-08-27  8:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-27  5:55 Riyan Dhiman
2024-08-27  8:40 ` Dan Carpenter [this message]
2024-08-27  9:09 Riyan Dhiman
2024-08-27  9:40 ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8d62104c-ac1f-447a-8b53-cad4e66a6c8d@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=riyandhiman14@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®