[PATCH linux dev-4.10 v4 19/31] drivers: fsi: occ: Return ENODEV if client is NULL

Andrew Jeffery andrew at aj.id.au
Fri Oct 6 13:12:55 AEDT 2017


On Thu, 2017-10-05 at 21:05 -0500, Eddie James wrote:
> From: "Edward A. James" <eajames at us.ibm.com>
> 
> Safeguard the access functions.
> 
> Signed-off-by: Edward A. James <eajames at us.ibm.com>

Reviewed-by: Andrew Jeffery <andrew at aj.id.au>

> ---
>  drivers/fsi/occ.c | 24 ++++++++++++++++++++----
>  1 file changed, 20 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/fsi/occ.c b/drivers/fsi/occ.c
> index 55f293d..322af5a 100644
> --- a/drivers/fsi/occ.c
> +++ b/drivers/fsi/occ.c
> @@ -168,11 +168,16 @@ static ssize_t occ_read_common(struct occ_client *client, char __user *ubuf,
>  {
>  	int rc;
>  	size_t bytes;
> -	struct occ_xfr *xfr = &client->xfr;
> +	struct occ_xfr *xfr;
> +
> +	if (!client)
> +		return -ENODEV;
>  
>  	if (len > OCC_SRAM_BYTES)
>  		return -EINVAL;
>  
> +	xfr = &client->xfr;
> +
>  	spin_lock_irq(&client->lock);
>  
>  	if (!test_bit(CLIENT_XFR_PENDING, &client->flags)) {
> @@ -263,11 +268,16 @@ static ssize_t occ_write_common(struct occ_client *client,
>  	int rc;
>  	unsigned int i;
>  	u16 data_length, checksum = 0;
> -	struct occ_xfr *xfr = &client->xfr;
> +	struct occ_xfr *xfr;
> +
> +	if (!client)
> +		return -ENODEV;
>  
>  	if (len > (OCC_CMD_DATA_BYTES + 3) || len < 3)
>  		return -EINVAL;
>  
> +	xfr = &client->xfr;
> +
>  	spin_lock_irq(&client->lock);
>  	if (test_and_set_bit(CLIENT_XFR_PENDING, &client->flags)) {
>  		rc = -EBUSY;
> @@ -327,8 +337,14 @@ static ssize_t occ_write(struct file *file, const char __user *buf,
>  
>  static int occ_release_common(struct occ_client *client)
>  {
> -	struct occ_xfr *xfr = &client->xfr;
> -	struct occ *occ = client->occ;
> +	struct occ *occ;
> +	struct occ_xfr *xfr;
> +
> +	if (!client)
> +		return -ENODEV;
> +
> +	xfr = &client->xfr;
> +	occ = client->occ;
>  
>  	spin_lock_irq(&client->lock);
>  
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: This is a digitally signed message part
URL: <http://lists.ozlabs.org/pipermail/openbmc/attachments/20171006/a3b6d029/attachment.sig>


More information about the openbmc mailing list