DriverDev-Devel Archive on lore.kernel.org
 help / color / Atom feed
* staging: exfat: issue with FFS_MEDIAERR error return assignment
@ 2019-08-30 18:38 Colin Ian King
  2019-09-10 12:44 ` Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Colin Ian King @ 2019-08-30 18:38 UTC (permalink / raw)
  To: Valdis Kletnieks, Greg Kroah-Hartman, devel; +Cc: linux-kernel

Hi,

Static analysis on exfat with Coverity has picked up an assignment of
FFS_MEDIAERR that gets over-written:


1750        if (is_dir) {
1751                if ((fid->dir.dir == p_fs->root_dir) &&
1752                    (fid->entry == -1)) {
1753                        if (p_fs->dev_ejected)

    CID 85797 (#1 of 1): Unused value (UNUSED_VALUE)
Assigning value 1 to ret here, but that stored value is overwritten
before it can be used.

1754                                ret = FFS_MEDIAERR;

    value_overwrite: Overwriting previous write to ret with value 0.

1755                        ret = FFS_SUCCESS;
1756                        goto out;
1757                }
1758        }

I doubt that's intentional, should it be instead the following?

				if (p_fs->dev_ejected)
					ret = FFS_MEDIAERR;
				else
					ret = FFS_SUCCESS;
				goto out;

Colin
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: staging: exfat: issue with FFS_MEDIAERR error return assignment
  2019-08-30 18:38 staging: exfat: issue with FFS_MEDIAERR error return assignment Colin Ian King
@ 2019-09-10 12:44 ` Dan Carpenter
  2019-09-10 12:58   ` Colin Ian King
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2019-09-10 12:44 UTC (permalink / raw)
  To: Colin Ian King; +Cc: devel, Greg Kroah-Hartman, Valdis Kletnieks, linux-kernel

On Fri, Aug 30, 2019 at 07:38:00PM +0100, Colin Ian King wrote:
> Hi,
> 
> Static analysis on exfat with Coverity has picked up an assignment of
> FFS_MEDIAERR that gets over-written:
> 
> 
> 1750        if (is_dir) {
> 1751                if ((fid->dir.dir == p_fs->root_dir) &&
> 1752                    (fid->entry == -1)) {
> 1753                        if (p_fs->dev_ejected)

Idealy we would have both a filename and a function name but this email
doesn't have either so no one knows what code you are talking about.  :P

regards,
dan carpenter
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: staging: exfat: issue with FFS_MEDIAERR error return assignment
  2019-09-10 12:44 ` Dan Carpenter
@ 2019-09-10 12:58   ` Colin Ian King
  2019-09-10 13:09     ` Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Colin Ian King @ 2019-09-10 12:58 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: devel, Greg Kroah-Hartman, Valdis Kletnieks, linux-kernel

On 10/09/2019 13:44, Dan Carpenter wrote:
> On Fri, Aug 30, 2019 at 07:38:00PM +0100, Colin Ian King wrote:
>> Hi,
>>
>> Static analysis on exfat with Coverity has picked up an assignment of
>> FFS_MEDIAERR that gets over-written:
>>
>>
>> 1750        if (is_dir) {
>> 1751                if ((fid->dir.dir == p_fs->root_dir) &&
>> 1752                    (fid->entry == -1)) {
>> 1753                        if (p_fs->dev_ejected)
> 
> Idealy we would have both a filename and a function name but this email
> doesn't have either so no one knows what code you are talking about.  :P

Oops, my bad.

drivers/staging/exfat/exfat_super.c ffsWriteStat()

> 
> regards,
> dan carpenter
> 

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: staging: exfat: issue with FFS_MEDIAERR error return assignment
  2019-09-10 12:58   ` Colin Ian King
@ 2019-09-10 13:09     ` Dan Carpenter
  2019-09-10 13:18       ` Valdis Klētnieks
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2019-09-10 13:09 UTC (permalink / raw)
  To: Colin Ian King; +Cc: devel, Greg Kroah-Hartman, Valdis Kletnieks, linux-kernel

On Tue, Sep 10, 2019 at 01:58:35PM +0100, Colin Ian King wrote:
> On 10/09/2019 13:44, Dan Carpenter wrote:
> > On Fri, Aug 30, 2019 at 07:38:00PM +0100, Colin Ian King wrote:
> >> Hi,
> >>
> >> Static analysis on exfat with Coverity has picked up an assignment of
> >> FFS_MEDIAERR that gets over-written:
> >>
> >>
> >> 1750        if (is_dir) {
> >> 1751                if ((fid->dir.dir == p_fs->root_dir) &&
> >> 1752                    (fid->entry == -1)) {
> >> 1753                        if (p_fs->dev_ejected)
> > 
> > Idealy we would have both a filename and a function name but this email
> > doesn't have either so no one knows what code you are talking about.  :P
> 
> Oops, my bad.
> 
> drivers/staging/exfat/exfat_super.c ffsWriteStat()

Yes, your solution is correct.

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: staging: exfat: issue with FFS_MEDIAERR error return assignment
  2019-09-10 13:09     ` Dan Carpenter
@ 2019-09-10 13:18       ` Valdis Klētnieks
  0 siblings, 0 replies; 5+ messages in thread
From: Valdis Klētnieks @ 2019-09-10 13:18 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: devel, Colin Ian King, linux-kernel, Greg Kroah-Hartman

[-- Attachment #1.1: Type: text/plain, Size: 1044 bytes --]

On Tue, 10 Sep 2019 16:09:35 +0300, Dan Carpenter said:
> On Tue, Sep 10, 2019 at 01:58:35PM +0100, Colin Ian King wrote:
> > On 10/09/2019 13:44, Dan Carpenter wrote:
> > > On Fri, Aug 30, 2019 at 07:38:00PM +0100, Colin Ian King wrote:
> > >> Hi,
> > >>
> > >> Static analysis on exfat with Coverity has picked up an assignment of
> > >> FFS_MEDIAERR that gets over-written:
> > >>
> > >>
> > >> 1750        if (is_dir) {
> > >> 1751                if ((fid->dir.dir == p_fs->root_dir) &&
> > >> 1752                    (fid->entry == -1)) {
> > >> 1753                        if (p_fs->dev_ejected)
> > >
> > > Idealy we would have both a filename and a function name but this email
> > > doesn't have either so no one knows what code you are talking about.  :P
> >
> > Oops, my bad.
> >
> > drivers/staging/exfat/exfat_super.c ffsWriteStat()
>
> Yes, your solution is correct.

Actually, you can skip the else, because we initialized 'ret' at the start of the function.

The *bigger* issue - what should 'ret' be if dev_ejected is *false*?

[-- Attachment #1.2: Type: application/pgp-signature, Size: 832 bytes --]

[-- Attachment #2: Type: text/plain, Size: 169 bytes --]

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-30 18:38 staging: exfat: issue with FFS_MEDIAERR error return assignment Colin Ian King
2019-09-10 12:44 ` Dan Carpenter
2019-09-10 12:58   ` Colin Ian King
2019-09-10 13:09     ` Dan Carpenter
2019-09-10 13:18       ` Valdis Klētnieks

DriverDev-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/driverdev-devel/0 driverdev-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 driverdev-devel driverdev-devel/ https://lore.kernel.org/driverdev-devel \
		driverdev-devel@linuxdriverproject.org devel@driverdev.osuosl.org driverdev-devel@archiver.kernel.org
	public-inbox-index driverdev-devel


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.linuxdriverproject.driverdev-devel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox