mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Domen Puncer <domen@coderock.org>
To: Jesper Juhl <juhl-lkml@dif.dk>
Cc: Steve French <sfrench@samba.org>,
	Steve French <sfrench@us.ibm.com>,
	samba-technical@lists.samba.org, linux-kernel@vger.kernel.org
Subject: Re: in cifssmb.c add copy_from_user return value check and do minor formatting/whitespace cleanups.
Date: Wed, 22 Dec 2004 00:54:24 +0100	[thread overview]
Message-ID: <20041221235424.GA19274@nd47.coderock.org> (raw)
In-Reply-To: <Pine.LNX.4.61.0412220021580.3518@dragon.hygekrogen.localhost>

On 22/12/04 00:33 +0100, Jesper Juhl wrote:
> 
> Hi, 
> 
> Seeing this warning :
> 
> fs/cifs/cifssmb.c:902: warning: ignoring return value of `copy_from_user', declared with attribute warn_unused_result
> 
> lead to the following patch.
> 
> The patch adds a check of the copy_from_user return value and returns 
> -EFAULT if the call fails. In addition to that I did some 
> formatting/whitespace changes - the code uses primarily tabs for 
> indentation, but this little bit used spaces, so I changed that to tabs; I 
> also added a few curly braces {} for a few if statements, in the same 
> area, that seemed to be becomming quite hard to read without.
> 
> Patch has been compile tested, but I have no real way to test it properly 
> beyond that. 
> I hope the patch is acceptable and mergable :)
> 
> Btw, I'm only subscribed to LKML, so please keep me on CC.
> 
> 
> Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>
> 
> diff -up linux-2.6.10-rc3-bk13-orig/fs/cifs/cifssmb.c linux-2.6.10-rc3-bk13/fs/cifs/cifssmb.c
> --- linux-2.6.10-rc3-bk13-orig/fs/cifs/cifssmb.c	2004-12-20 22:19:42.000000000 +0100
> +++ linux-2.6.10-rc3-bk13/fs/cifs/cifssmb.c	2004-12-22 00:21:38.000000000 +0100
> @@ -895,14 +895,19 @@ CIFSSMBWrite(const int xid, struct cifsT
>  		bytes_sent = count;
>  	pSMB->DataLengthHigh = 0;
>  	pSMB->DataOffset =
> -	    cpu_to_le16(offsetof(struct smb_com_write_req,Data) - 4);
> -    if(buf)
> -	    memcpy(pSMB->Data,buf,bytes_sent);
> -	else if(ubuf)
> -		copy_from_user(pSMB->Data,ubuf,bytes_sent);
> -    else {
> +		cpu_to_le16(offsetof(struct smb_com_write_req,Data) - 4);
> +
> +	if (buf) {
> +		memcpy(pSMB->Data,buf,bytes_sent);
> +	} else if (ubuf) {
> +		if (copy_from_user(pSMB->Data,ubuf,bytes_sent)) {
> +			if (pSMB)

How can this be NULL, and code not Oopsing?

> +				cifs_buf_release(pSMB);
> +			return -EFAULT;
> +		}
> +	} else {
>  		/* No buffer */
> -		if(pSMB)
> +		if (pSMB)

Same here.

>  			cifs_buf_release(pSMB);
>  		return -EINVAL;
>  	}
> 
> 
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

  reply	other threads:[~2004-12-21 23:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-21 23:33 [PATCH] " Jesper Juhl
2004-12-21 23:54 ` Domen Puncer [this message]
2004-12-22  0:27   ` Jesper Juhl
2004-12-22  1:03     ` [third patch version] " Jesper Juhl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20041221235424.GA19274@nd47.coderock.org \
    --to=domen@coderock.org \
    --cc=juhl-lkml@dif.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=samba-technical@lists.samba.org \
    --cc=sfrench@samba.org \
    --cc=sfrench@us.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®