* [PATCH v2] paride/pcd: return earlier when an error happens in pcd_atapi()
@ 2023-01-22 15:49 Tom Rix
2023-01-22 20:49 ` Jens Axboe
0 siblings, 1 reply; 5+ messages in thread
From: Tom Rix @ 2023-01-22 15:49 UTC (permalink / raw)
To: tim, axboe, nathan, ndesaulniers; +Cc: linux-block, linux-kernel, llvm, Tom Rix
clang static analysis reports
drivers/block/paride/pcd.c:856:36: warning: The left operand of '&'
is a garbage value [core.UndefinedBinaryOperatorResult]
tocentry->cdte_ctrl = buffer[5] & 0xf;
~~~~~~~~~ ^
When the call to pcd_atapi() fails, buffer[] is in an unknown state,
so return early.
Signed-off-by: Tom Rix <trix@redhat.com>
---
v2: remove unused 'r' variable
---
drivers/block/paride/pcd.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c
index a5ab40784119..47757ba1a09f 100644
--- a/drivers/block/paride/pcd.c
+++ b/drivers/block/paride/pcd.c
@@ -825,14 +825,14 @@ static int pcd_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void
struct cdrom_tochdr *tochdr =
(struct cdrom_tochdr *) arg;
char buffer[32];
- int r;
- r = pcd_atapi(cd, cmd, 12, buffer, "read toc header");
+ if (pcd_atapi(cd, cmd, 12, buffer, "read toc header"))
+ return -EIO;
tochdr->cdth_trk0 = buffer[2];
tochdr->cdth_trk1 = buffer[3];
- return r ? -EIO : 0;
+ return 0;
}
case CDROMREADTOCENTRY:
@@ -845,13 +845,13 @@ static int pcd_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void
struct cdrom_tocentry *tocentry =
(struct cdrom_tocentry *) arg;
unsigned char buffer[32];
- int r;
cmd[1] =
(tocentry->cdte_format == CDROM_MSF ? 0x02 : 0);
cmd[6] = tocentry->cdte_track;
- r = pcd_atapi(cd, cmd, 12, buffer, "read toc entry");
+ if (pcd_atapi(cd, cmd, 12, buffer, "read toc entry"))
+ return -EIO;
tocentry->cdte_ctrl = buffer[5] & 0xf;
tocentry->cdte_adr = buffer[5] >> 4;
@@ -866,7 +866,7 @@ static int pcd_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void
(((((buffer[8] << 8) + buffer[9]) << 8)
+ buffer[10]) << 8) + buffer[11];
- return r ? -EIO : 0;
+ return 0;
}
default:
--
2.26.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] paride/pcd: return earlier when an error happens in pcd_atapi()
2023-01-22 15:49 [PATCH v2] paride/pcd: return earlier when an error happens in pcd_atapi() Tom Rix
@ 2023-01-22 20:49 ` Jens Axboe
2023-01-22 21:57 ` Tom Rix
2023-01-22 22:10 ` Al Viro
0 siblings, 2 replies; 5+ messages in thread
From: Jens Axboe @ 2023-01-22 20:49 UTC (permalink / raw)
To: Tom Rix, tim, nathan, ndesaulniers; +Cc: linux-block, linux-kernel, llvm
On 1/22/23 8:49 AM, Tom Rix wrote:
> clang static analysis reports
> drivers/block/paride/pcd.c:856:36: warning: The left operand of '&'
> is a garbage value [core.UndefinedBinaryOperatorResult]
> tocentry->cdte_ctrl = buffer[5] & 0xf;
> ~~~~~~~~~ ^
Has this one been compiled? I'm guessing not tested...
In any case, this code is going away hopefully shortly, so let's not
bother with changes like this.
--
Jens Axboe
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] paride/pcd: return earlier when an error happens in pcd_atapi()
2023-01-22 20:49 ` Jens Axboe
@ 2023-01-22 21:57 ` Tom Rix
2023-01-22 22:10 ` Al Viro
1 sibling, 0 replies; 5+ messages in thread
From: Tom Rix @ 2023-01-22 21:57 UTC (permalink / raw)
To: Jens Axboe, tim, nathan, ndesaulniers; +Cc: linux-block, linux-kernel, llvm
On 1/22/23 12:49 PM, Jens Axboe wrote:
> On 1/22/23 8:49 AM, Tom Rix wrote:
>> clang static analysis reports
>> drivers/block/paride/pcd.c:856:36: warning: The left operand of '&'
>> is a garbage value [core.UndefinedBinaryOperatorResult]
>> tocentry->cdte_ctrl = buffer[5] & 0xf;
>> ~~~~~~~~~ ^
> Has this one been compiled? I'm guessing not tested...
>
> In any case, this code is going away hopefully shortly, so let's not
> bother with changes like this.
Going away soon would be nice, this is an old problem.
I did not bother with a fixes: tag because it was is when the repo was
created in 2005.
Tom
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] paride/pcd: return earlier when an error happens in pcd_atapi()
2023-01-22 20:49 ` Jens Axboe
2023-01-22 21:57 ` Tom Rix
@ 2023-01-22 22:10 ` Al Viro
2023-01-22 22:27 ` Jens Axboe
1 sibling, 1 reply; 5+ messages in thread
From: Al Viro @ 2023-01-22 22:10 UTC (permalink / raw)
To: Jens Axboe
Cc: Tom Rix, tim, nathan, ndesaulniers, linux-block, linux-kernel,
llvm
On Sun, Jan 22, 2023 at 01:49:00PM -0700, Jens Axboe wrote:
> On 1/22/23 8:49 AM, Tom Rix wrote:
> > clang static analysis reports
> > drivers/block/paride/pcd.c:856:36: warning: The left operand of '&'
> > is a garbage value [core.UndefinedBinaryOperatorResult]
> > tocentry->cdte_ctrl = buffer[5] & 0xf;
> > ~~~~~~~~~ ^
>
> Has this one been compiled? I'm guessing not tested...
>
> In any case, this code is going away hopefully shortly, so let's not
> bother with changes like this.
Look at the callers - the value left in entry is discarded if
->audio_ioctl(..., CDROMREADTOCENTRY, &entry) returns non-zero. Sure,
it's a nasal daemon territory, but realistically it's not going to be
caught by testing.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] paride/pcd: return earlier when an error happens in pcd_atapi()
2023-01-22 22:10 ` Al Viro
@ 2023-01-22 22:27 ` Jens Axboe
0 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2023-01-22 22:27 UTC (permalink / raw)
To: Al Viro; +Cc: Tom Rix, tim, nathan, ndesaulniers, linux-block, linux-kernel,
llvm
On 1/22/23 3:10 PM, Al Viro wrote:
> On Sun, Jan 22, 2023 at 01:49:00PM -0700, Jens Axboe wrote:
>> On 1/22/23 8:49 AM, Tom Rix wrote:
>>> clang static analysis reports
>>> drivers/block/paride/pcd.c:856:36: warning: The left operand of '&'
>>> is a garbage value [core.UndefinedBinaryOperatorResult]
>>> tocentry->cdte_ctrl = buffer[5] & 0xf;
>>> ~~~~~~~~~ ^
>>
>> Has this one been compiled? I'm guessing not tested...
>>
>> In any case, this code is going away hopefully shortly, so let's not
>> bother with changes like this.
>
> Look at the callers - the value left in entry is discarded if
> ->audio_ioctl(..., CDROMREADTOCENTRY, &entry) returns non-zero. Sure,
> it's a nasal daemon territory, but realistically it's not going to be
> caught by testing.
I don't expect anyone really to be able to test it, but v1 had a pretty
basic issue that would've surely triggered a compiler warning had it
been compiled.
--
Jens Axboe
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-01-22 22:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-22 15:49 [PATCH v2] paride/pcd: return earlier when an error happens in pcd_atapi() Tom Rix
2023-01-22 20:49 ` Jens Axboe
2023-01-22 21:57 ` Tom Rix
2023-01-22 22:10 ` Al Viro
2023-01-22 22:27 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).