From: Tom Rix <trix@redhat.com>
To: tim@cyberelk.net, axboe@kernel.dk, nathan@kernel.org,
ndesaulniers@google.com
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, Tom Rix <trix@redhat.com>
Subject: [PATCH v2] paride/pcd: return earlier when an error happens in pcd_atapi()
Date: Sun, 22 Jan 2023 07:49:01 -0800 [thread overview]
Message-ID: <20230122154901.505142-1-trix@redhat.com> (raw)
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
next reply other threads:[~2023-01-22 15:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-22 15:49 Tom Rix [this message]
2023-01-22 20:49 ` [PATCH v2] paride/pcd: return earlier when an error happens in pcd_atapi() Jens Axboe
2023-01-22 21:57 ` Tom Rix
2023-01-22 22:10 ` Al Viro
2023-01-22 22:27 ` Jens Axboe
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=20230122154901.505142-1-trix@redhat.com \
--to=trix@redhat.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=tim@cyberelk.net \
/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 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.