All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio/scmi: check if dev is null pointer
@ 2021-10-08  6:29 Jiasheng Jiang
  2021-10-08  9:01 ` Lars-Peter Clausen
  0 siblings, 1 reply; 2+ messages in thread
From: Jiasheng Jiang @ 2021-10-08  6:29 UTC (permalink / raw)
  To: jbhayana, jic23, lars; +Cc: linux-iio, linux-kernel, Jiasheng Jiang

The parameter 'dev' of scmi_iio_dev_probe() isn't been
checked before used, including when scmi_iio_dev_probe() is called.
Therefore, it might be better to check, just in case.

Fixes: 25cbdd4 ("iio/scmi: Port driver to the new scmi_sensor_proto_ops interface")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 drivers/iio/common/scmi_sensors/scmi_iio.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/iio/common/scmi_sensors/scmi_iio.c b/drivers/iio/common/scmi_sensors/scmi_iio.c
index 141e8aa..d3ff985 100644
--- a/drivers/iio/common/scmi_sensors/scmi_iio.c
+++ b/drivers/iio/common/scmi_sensors/scmi_iio.c
@@ -592,6 +592,9 @@ static int scmi_iio_dev_probe(struct scmi_device *sdev)
 
 	if (!handle)
 		return -ENODEV;
+
+	if (!dev)
+		return -ENODEV;
 
 	sensor_ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_SENSOR, &ph);
 	if (IS_ERR(sensor_ops)) {
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] iio/scmi: check if dev is null pointer
  2021-10-08  6:29 [PATCH] iio/scmi: check if dev is null pointer Jiasheng Jiang
@ 2021-10-08  9:01 ` Lars-Peter Clausen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars-Peter Clausen @ 2021-10-08  9:01 UTC (permalink / raw)
  To: Jiasheng Jiang, jbhayana, jic23; +Cc: linux-iio, linux-kernel

On 10/8/21 8:29 AM, Jiasheng Jiang wrote:
> The parameter 'dev' of scmi_iio_dev_probe() isn't been
> checked before used, including when scmi_iio_dev_probe() is called.
> Therefore, it might be better to check, just in case.
>
> Fixes: 25cbdd4 ("iio/scmi: Port driver to the new scmi_sensor_proto_ops interface")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>

Hi,

Thanks for the patch.

Is there anything that makes you think dev could ever be NULL? dev is a 
pointer to a field in `sdev`. So for `dev` to be NULL sdev would have to 
be `-offsetof(struct scmi_device, dev)`.


- Lars

> ---
>   drivers/iio/common/scmi_sensors/scmi_iio.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/drivers/iio/common/scmi_sensors/scmi_iio.c b/drivers/iio/common/scmi_sensors/scmi_iio.c
> index 141e8aa..d3ff985 100644
> --- a/drivers/iio/common/scmi_sensors/scmi_iio.c
> +++ b/drivers/iio/common/scmi_sensors/scmi_iio.c
> @@ -592,6 +592,9 @@ static int scmi_iio_dev_probe(struct scmi_device *sdev)
>   
>   	if (!handle)
>   		return -ENODEV;
> +
> +	if (!dev)
> +		return -ENODEV;
>   
>   	sensor_ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_SENSOR, &ph);
>   	if (IS_ERR(sensor_ops)) {



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-08  9:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-08  6:29 [PATCH] iio/scmi: check if dev is null pointer Jiasheng Jiang
2021-10-08  9:01 ` Lars-Peter Clausen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.