max1720x_battery: check argumets on GPL functions

Return an error when the parameters passed to public functions are invalid.

Bug: 184308977
Signed-off-by: AleX Pelosi <[email protected]>
Change-Id: I29558b82abc3c9f61567d6820c1d8d3f0fa6360c
diff --git a/max1720x_battery.c b/max1720x_battery.c
index 8609132..9a0721a 100644
--- a/max1720x_battery.c
+++ b/max1720x_battery.c
@@ -984,10 +984,14 @@
 
 int max1720x_get_capacity(struct i2c_client *client, int *iic_raw)
 {
-	struct max1720x_chip *chip = i2c_get_clientdata(client);
+	struct max1720x_chip *chip;
 	u16 temp;
 	int ret;
 
+	if (!client || !iic_raw)
+		return -EINVAL;
+
+	chip = i2c_get_clientdata(client);
 	if (!chip)
 		return -ENODEV;
 
@@ -1006,6 +1010,9 @@
 	u16 temp;
 	int ret;
 
+	if (!client || !volt)
+		return -EINVAL;
+
 	chip = i2c_get_clientdata(client);
 	if (!chip)
 		return -ENODEV;