Re: [PATCH 2/2] usb: typec: tipd: Add an additional overflow check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 14, 2021 at 12:42:53PM +0200, Sven Peter wrote:
> tps6598x_block_read already checks for the maximum length of the read
> but tps6598x_block_write does not. Add the symmetric check there as
> well.
> 
> Signed-off-by: Sven Peter <sven@xxxxxxxxxxxxx>
> ---
>  drivers/usb/typec/tipd/core.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
> index c18ec3785592..70e2d0d410c9 100644
> --- a/drivers/usb/typec/tipd/core.c
> +++ b/drivers/usb/typec/tipd/core.c
> @@ -139,6 +139,9 @@ static int tps6598x_block_write(struct tps6598x *tps, u8 reg,
>  {
>  	u8 data[TPS_MAX_LEN + 1];
>  
> +	if (WARN_ON(len + 1 > sizeof(data)))
> +		return -EINVAL;

No need to crash anything.  If this is a valid thing for us to check,
let's check it and handle the error, but we should not reboot systems
that are running with panic-on-warn enabled, right?

thanks,

greg k-h



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux