@@ -2445,8 +2445,6 @@ static void sienna_cichlid_fill_i2c_req(SwI2cRequest_t *req, bool write,
24452445{
24462446 int i ;
24472447
2448- BUG_ON (numbytes > MAX_SW_I2C_COMMANDS );
2449-
24502448 req -> I2CcontrollerPort = 0 ;
24512449 req -> I2CSpeed = 2 ;
24522450 req -> SlaveAddress = address ;
@@ -2484,6 +2482,12 @@ static int sienna_cichlid_i2c_read_data(struct i2c_adapter *control,
24842482 struct smu_table_context * smu_table = & adev -> smu .smu_table ;
24852483 struct smu_table * table = & smu_table -> driver_table ;
24862484
2485+ if (numbytes > MAX_SW_I2C_COMMANDS ) {
2486+ dev_err (adev -> dev , "numbytes requested %d is over max allowed %d\n" ,
2487+ numbytes , MAX_SW_I2C_COMMANDS );
2488+ return - EINVAL ;
2489+ }
2490+
24872491 memset (& req , 0 , sizeof (req ));
24882492 sienna_cichlid_fill_i2c_req (& req , false, address , numbytes , data );
24892493
@@ -2520,6 +2524,12 @@ static int sienna_cichlid_i2c_write_data(struct i2c_adapter *control,
25202524 SwI2cRequest_t req ;
25212525 struct amdgpu_device * adev = to_amdgpu_device (control );
25222526
2527+ if (numbytes > MAX_SW_I2C_COMMANDS ) {
2528+ dev_err (adev -> dev , "numbytes requested %d is over max allowed %d\n" ,
2529+ numbytes , MAX_SW_I2C_COMMANDS );
2530+ return - EINVAL ;
2531+ }
2532+
25232533 memset (& req , 0 , sizeof (req ));
25242534 sienna_cichlid_fill_i2c_req (& req , true, address , numbytes , data );
25252535
0 commit comments