diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c index 63f6eb9030d1..9d383ec77203 100644 --- a/drivers/hid/hid-playstation.c +++ b/drivers/hid/hid-playstation.c @@ -1994,6 +1994,7 @@ static int dualshock4_get_calibration_data(struct dualshock4 *ds4) /* Done parsing the buffer, so let's free it. */ kfree(buf); + buf = NULL; /* * Set gyroscope calibration and normalization parameters. @@ -2041,6 +2042,10 @@ static int dualshock4_get_calibration_data(struct dualshock4 *ds4) ds4->accel_calib_data[2].sens_denom = range_2g; transfer_failed: + /* First free buf if still allocated */ + if(buf) + kfree(buf); + /* * Sanity check gyro calibration data. This is needed to prevent crashes * during report handling of virtual, clone or broken devices not implementing